GaussianPosterior#
- class torchbayesian.bnn.GaussianPosterior(shape: Size | list[int] | tuple[int, ...], *, dtype: dtype | None = None, device: device | str | int | None = None)#
Bases:
VariationalPosteriorThis class is a diagonal Gaussian variational posterior.
Samples tensors via the reparametrization trick.
This is a commonly used variational posterior for Bayes by Backprop (BBB) variational inference (VI), as described in “Weight Uncertainty in Neural Networks” by Blundell et al.
Parameters#
- shape_size
The shape of the parameter being replaced by the variational posterior.
- dtypeOptional[_dtype]
The dtype of the parameter being replaced by the variational posterior. Optional. Defaults to torch default dtype.
- deviceDevice
The device of the parameter being replaced by the variational posterior. Optional. Defaults to torch default device.
Attributes#
- muParameter
The variational parameter of the mean of the distribution.
- rhoParameter
The variational parameter that parametrizes the standard deviation of the distribution via softplus.
- reset_parameters() None#
Initializes the variational parameters ‘mu’ and ‘rho’ of the Gaussian posterior N(mu, sigma), where sigma = softplus(rho).
- property sigma: Tensor#
Returns the standard deviation parameter of the Gaussian distribution.
Returns#
- sigmaTensor
The standard deviation parameter of the Gaussian distribution