Prior#
- class torchbayesian.bnn.Prior#
Bases:
ABCThis class serves as a base class for all priors used for Bayes by backprop (BBB) variational inference (VI).
Base class implemented for consistency in the case of possible future implementation of learnable priors and making Prior a child of ‘nn.Module’ similarly to ‘bnn.VariationalPosterior’.
Warning#
Subclasses of ‘Prior’ used in ‘bnn.BayesianModule’ must work with ‘get_prior()’; their constructor (‘__init__’) method must accept arguments ‘shape’, ‘dtype’ and ‘device’.
- abstract property distribution: Distribution#
A ‘torch.distributions.Distribution’ corresponding to the prior.
This is used for KL computation aligned with PyTorch’s framework.
Returns#
- distributionDistribution
A ‘torch.distributions.Distribution’ corresponding to the prior.
- extra_repr() str#
Returns the extra representation of the prior.
To print customized extra information, you should re-implement this method in your own priors. Both single-line and multi-line strings are acceptable.