ab.distributions¶
Helper functions for model parameter distributions.
-
aboleth.distributions.
gaus_posterior
(dim, std0)¶ Initialise a posterior Gaussian distribution with a diagonal covariance.
Even though this is initialised with a diagonal covariance, a full covariance will be learned, using a lower triangular Cholesky parameterisation.
Parameters: - dim (tuple or list) – the dimension of this distribution.
- std0 (float) – the initial (unoptimized) diagonal standard deviation of this distribution.
Returns: Q – the initialised posterior Gaussian object.
Return type: tf.contrib.distributions.MultivariateNormalTriL
Note
This will make tf.Variables on the randomly initialised mean and covariance of the posterior. The initialisation of the mean is from a Normal with zero mean, and
std0
standard deviation, and the initialisation of the (lower triangular of the) covariance is from a gamma distribution with an alpha ofstd0
and a beta of 1.
-
aboleth.distributions.
kl_sum
(q, p)¶ Compute the total KL between (potentially) many distributions.
I.e. \(\sum_i \text{KL}[q_i || p_i]\)
Parameters: - q (tf.distributions.Distribution) – A tensorflow Distribution object
- p (tf.distributions.Distribution) – A tensorflow Distribution object
Returns: kl – the result of the sum of the KL divergences of the
q
andp
distibutions.Return type: Tensor
-
aboleth.distributions.
norm_posterior
(dim, std0)¶ Initialise a posterior (diagonal) Normal distribution.
Parameters: - dim (tuple or list) – the dimension of this distribution.
- std0 (float) – the initial (unoptimized) standard deviation of this distribution.
Returns: Q – the initialised posterior Normal object.
Return type: tf.distributions.Normal
Note
This will make tf.Variables on the randomly initialised mean and standard deviation of the posterior. The initialisation of the mean is from a Normal with zero mean, and
std0
standard deviation, and the initialisation of the standard deviation is from a gamma distribution with an alpha ofstd0
and a beta of 1.
-
aboleth.distributions.
norm_prior
(dim, std)¶ Initialise a prior (zero mean, isotropic) Normal distribution.
Parameters: - dim (tuple or list) – the dimension of this distribution.
- std (float) – the prior standard deviation of this distribution.
Returns: P – the initialised prior Normal object.
Return type: tf.distributions.Normal
Note
This will make a tf.Variable on the variance of the prior that is initialised with
std
.