GaussianPrior#
- class torchbayesian.bnn.GaussianPrior(shape: Size | list[int] | tuple[int, ...] | None = None, mu: float | Tensor | None = None, sigma: float | Tensor | None = None, *, dtype: dtype | None = None, device: device | str | int | None = None)#
Bases:
PriorThis class is a diagonal Gaussian prior distribution used for Bayes by Backprop (BBB).
Parameters#
- shape_size
The supposed shape of the parameter for which to initialize a Prior.
- muOptional[float | Tensor]
The mean of the Gaussian prior distribution. Either a float that will be assigned to each element of the mean matrix or a Tensor whose shape, dtype and device match the mean matrix. Optional. Defaults to 0.
- sigmaOptional[float | Tensor]
The standard deviation of the Gaussian prior distribution. Either a float that will be assigned to each element of the std matrix or a Tensor whose shape, dtype and device match the std matrix. Optional. Defaults to 1.
- dtype: Optional[_dtype]
The supposed dtype of the parameter for which to initialize a Prior. Optional. Defaults to torch default dtype.
- device: Device
The supposed device of the parameter for which to initialize a Prior. Optional. Defaults to torch’s default device.
Attributes#
- muTensor
The mean of the diagonal Gaussian prior distribution.
- sigmaTensor
The standard deviation of the Gaussian prior distribution