get_prior#

torchbayesian.bnn.utils.get_prior(shape: Size | list[int] | tuple[int, ...], prior: str | Tuple[str, Dict[str, Any]], *, dtype: dtype | None = None, device: device | str | int | None = None) Prior#

Creates an instance of a ‘Prior’ subclass. For use in ‘bnn.BayesianModule’.

Parameters#

shape_size

The shape of the tensor for which to initialize a prior.

priorstr | Tuple[str, Dict[str, Any]]

The prior to instantiate. Either the prior’s name (str) or a tuple of the name and a dictionary of keyword arguments for instantiation.

dtypeOptional[_dtype]

The dtype of the tensor for which to initialize a prior. Optional. Defaults to torch’s default dtype.

deviceDevice

The device of the parameter or tensor for which to initialize a prior. Optional. Defaults to torch’s default device.

Returns#

prior_instancePrior

The instantiated prior.