gpflow.kullback_leiblers#
Functions#
gpflow.kullback_leiblers.gauss_kl#
- gpflow.kullback_leiblers.gauss_kl(q_mu, q_sqrt, K=None, *, K_cholesky=None)[source]#
Compute the KL divergence KL[q || p] between:
q(x) = N(q_mu, q_sqrt^2)
and:
p(x) = N(0, K) if K is not None p(x) = N(0, I) if K is None
We assume L multiple independent distributions, given by the columns of q_mu and the first or last dimension of q_sqrt. Returns the sum of the divergences.
q_mu is a matrix ([M, L]), each column contains a mean.
q_sqrt can be a 3D tensor ([L, M, M]), each matrix within is a lower triangular square-root matrix of the covariance of q.
q_sqrt can be a matrix ([M, L]), each column represents the diagonal of a square-root matrix of the covariance of q.
K is the covariance of p (positive-definite matrix). The K matrix can be passed either directly as K, or as its Cholesky factor, K_cholesky. In either case, it can be a single matrix [M, M], in which case the sum of the L KL divergences is computed by broadcasting, or L different covariances [L, M, M].
Note: if no K matrix is given (both K and K_cholesky are None), gauss_kl computes the KL divergence from p(x) = N(0, I) instead.
- Parameters:
q_mu (
Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –q_mu has shape [M, L].
q_sqrt (
Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –q_sqrt has shape [M_L_or_L_M_M…].
K (
Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –K has shape [broadcast L, M, M].
K_cholesky (
Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –K_cholesky has shape [broadcast L, M, M].
- Return type:
Tensor
- Returns:
return has shape [].
gpflow.kullback_leiblers.prior_kl#
This function uses multiple dispatch, which will depend on the type of argument passed in:
gpflow.kullback_leiblers.prior_kl( InducingVariables, Kernel, object, object )
# dispatch to -> gpflow.kullback_leiblers._(...)
- gpflow.kullback_leiblers._(inducing_variable, kernel, q_mu, q_sqrt, whiten=False)[source]#
- Parameters:
inducing_variable (
InducingVariables
) –kernel (
Kernel
) –q_mu (
Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –q_sqrt (
Union
[ndarray
[Any
,Any
],Tensor
,Variable
,Parameter
]) –whiten (
bool
) –
- Return type:
Tensor