torch_blue.vi.distributions.BasicQuietPrior
- class torch_blue.vi.distributions.BasicQuietPrior(std_ratio: float = 1.0, mean_mean: float = 0.0, mean_std: float = 1.0, eps: float = 1e-10)
Bases:
torch_blue.vi.distributions.base.DistributionPrior assuming normal distributed mean and std proportional to it.
This is an experimental, hierarchical prior that assumes uncorrelated, normal-distributed weights. However, instead of each having the same mean and standard deviation it assumes the means to be normal distributed amd each standard deviation to be proportional to the respective mean by a fixed factor.
The distribution parameters are “mean” and “log_std”.
This distribution is implemented only as a prior and requires the parameter mean to calculate
log_prob().- Parameters:
std_ratio (float, default: 1.0) – The fixed ratio between each pair of standard deviation and mean.
mean_mean (float, default: 0.0) – The mean of the distribution of means.
mean_std (float, default: 1.0) – The standard deviation of the distribution of means.
eps (float, default: 1e-10) – Epsilon for numerical stability.
- prior_log_prob(sample: torch.Tensor, mean: torch.Tensor) torch.Tensor
Compute the log probability of the sample based on the prior.
This calculates the Gaussian log probability of a sample using the current best estimate for its mean and adds a factor to account for the distribution of means.
All Tensors have the same shape.
This calculation is affected by
_globals._USE_NORM_CONSTANTS, which can be set withuse_norm_constants().- Parameters:
sample (Tensor) – A Tensor of values to calculate the log probability for.
mean (Tensor) – The current best estimate for the mean of ech value.
- Returns:
The log probability of the sample under the prior.
- Return type:
Tensor
- reset_parameters_to_prior(module: VIModule, variable: str) None
Reset the parameters of the module to prior mean and standard deviation.
This samples the means from the specified mean distribution and initializes the corresponding log standard deviations to according the ratio given by
std_ratio.- Parameters:
module (VIModule) – The module containing the parameters to reset.
variable (str) – The name of the random variable to reset as given by
variational_parametersof the associatedDistribution.
- Return type:
None