BayesianDropout#

class torchbayesian.bnn.BayesianDropout(p: float = 0.5, inplace: bool = False)#

Bases: _DropoutNd

This class is an implementation of ‘torch.nn.Dropout’ that remains active in eval mode.

This is used for Bayesian neural networks (BNN) via Monte Carlo dropout (MCD), as described in “Dropout as a Bayesian Approximation: Representing Model Uncertainty in Deep Learning” by Y. Gal and Z. Ghahramani.

Parameters#

pfloat

The probability of an element to be zeroed. Defaults to 0.5.

inplacebool

If set to ‘True’, will do this operation in-place. Defaults to ‘False’.

forward(input: Tensor) Tensor#

Forward pass.

Parameters#

inputTensor

The input Tensor.

Returns#

outputTensor

The output tensor