ab.distributions

Helper functions for model parameter distributions.

aboleth.distributions.gaus_posterior(dim, std0, suffix=None)

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.
  • suffix (str) – suffix to add to the names of the variables of the parameters of this distribution.
Returns:

Q – the initialised posterior Gaussian object.

Return type:

tf.contrib.distributions.MultivariateNormalTriL

Note

This will make tf.Variables on the mean and covariance of the posterior. The initialisation of the mean is zero, and the initialisation of the (lower triangular of the) covariance is from diagonal matrices with diagonal elements taking the value of std0.

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 and p distibutions.

Return type:

Tensor

aboleth.distributions.norm_posterior(dim, std0, suffix=None)

Initialise a posterior (diagonal) Normal distribution.

Parameters:
  • dim (tuple or list) – the dimension of this distribution.
  • std0 (float, np.array) – the initial (unoptimized) standard deviation of this distribution. Must be a scalar or have the same shape as dim.
  • suffix (str) – suffix to add to the names of the variables of the parameters of this distribution.
Returns:

Q – the initialised posterior Normal object.

Return type:

tf.distributions.Normal

Note

This will make tf.Variables on the mean standard deviation of the posterior. The initialisation of the mean is zero and the initialisation of the standard deviation is simply std0 for each element.

aboleth.distributions.norm_prior(dim, std)

Make a prior (zero mean, isotropic) Normal distribution.

Parameters:
  • dim (tuple or list) – the dimension of this distribution.
  • std (float, np.array, tf.Tensor, tf.Variable) – the prior standard deviation of this distribution.
Returns:

P – the initialised prior Normal object.

Return type:

tf.distributions.Normal