gpflow.conditionals.util#
Functions#
gpflow.conditionals.util.base_conditional_with_lm#
- gpflow.conditionals.util.base_conditional_with_lm(Kmn, Lm, Knn, f, *, full_cov=False, q_sqrt=None, white=False)[source]#
Has the same functionality as the base_conditional function, except that instead of Kmm this function accepts Lm, which is the Cholesky decomposition of Kmm.
This allows Lm to be precomputed, which can improve performance.
- Parameters:
Kmn (
Tensor
) –Kmn has shape [M, batch…, N].
Lm (
Tensor
) –Lm has shape [M, M].
Knn (
Tensor
) –Knn has shape [batch…, N, N] if full_cov.
Knn has shape [batch…, N] if not full_cov.
f (
Tensor
) –f has shape [M, R].
q_sqrt (
Optional
[Tensor
]) –q_sqrt has shape [M_R_or_R_M_M…].
full_cov (
bool
) –white (
bool
) –
- Return type:
Tuple
[Tensor
,Tensor
]- Returns:
return[0] has shape [batch…, N, R].
return[1] has shape [batch…, N, R] if not full_cov.
return[1] has shape [batch…, R, N, N] if full_cov.
gpflow.conditionals.util.expand_independent_outputs#
- gpflow.conditionals.util.expand_independent_outputs(fvar, full_cov, full_output_cov)[source]#
Reshapes fvar to the correct shape, specified by full_cov and full_output_cov.
- Parameters:
fvar (
Tensor
) –fvar has shape [batch…, N, P] if not full_cov.
fvar has shape [batch…, P, N, N] if full_cov.
Single-output covariance.
full_cov (
bool
) –full_output_cov (
bool
) –
- Return type:
Tensor
- Returns:
return has shape [batch…, N, P, N, P] if full_cov and full_output_cov.
return has shape [batch…, N, P, P] if (not full_cov) and full_output_cov.
return has shape [batch…, N, P] if (not full_cov) and (not full_output_cov).
return has shape [batch…, P, N, N] if full_cov and (not full_output_cov).
Multi-output covariance.
gpflow.conditionals.util.independent_interdomain_conditional#
- gpflow.conditionals.util.independent_interdomain_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False)[source]#
The inducing outputs live in the g-space (R^L).
Interdomain conditional calculation.
- Parameters:
full_cov (
bool
) – calculate covariance between inputsfull_output_cov (
bool
) – calculate covariance between outputswhite (
bool
) – use whitened representationKmn (
Tensor
) –Kmn has shape [M, L, N, P].
Kmm (
Tensor
) –Kmm has shape [L, M, M].
Knn (
Tensor
) –Knn has shape [N, P, N, P] if full_cov and full_output_cov.
Knn has shape [N, P, P] if (not full_cov) and full_output_cov.
Knn has shape [N, P] if (not full_cov) and (not full_output_cov).
Knn has shape [P, N, N] if full_cov and (not full_output_cov).
f (
Tensor
) –f has shape [M, L].
q_sqrt (
Optional
[Tensor
]) –q_sqrt has shape [M_L_or_L_M_M…].
- Return type:
Tuple
[Tensor
,Tensor
]- Returns:
return[0] has shape [N, P].
return[1] has shape [N, P, N, P] if full_cov and full_output_cov.
return[1] has shape [N, P, P] if (not full_cov) and full_output_cov.
return[1] has shape [N, P] if (not full_cov) and (not full_output_cov).
return[1] has shape [P, N, N] if full_cov and (not full_output_cov).
mean, variance
gpflow.conditionals.util.mix_latent_gp#
- gpflow.conditionals.util.mix_latent_gp(W, g_mean, g_var, full_cov, full_output_cov)[source]#
Takes the mean and variance of an uncorrelated L-dimensional latent GP and returns the mean and the variance of the mixed GP, f = W g, where both f and g are GPs.
- Return type:
Tuple
[Tensor
,Tensor
]- Returns:
return[0] has shape [batch…, N, P].
return[1] has shape [batch…, N, P, N, P] if full_cov and full_output_cov.
return[1] has shape [batch…, N, P, P] if (not full_cov) and full_output_cov.
return[1] has shape [batch…, N, P] if (not full_cov) and (not full_output_cov).
return[1] has shape [batch…, P, N, N] if full_cov and (not full_output_cov).
f_mean and f_var
- Parameters:
W (
Tensor
) –W has shape [P, L].
g_mean (
Tensor
) –g_mean has shape [batch…, N, L].
g_var (
Tensor
) –g_var has shape [L, batch…, N, N] if full_cov.
g_var has shape [batch…, N, L] if not full_cov.
full_cov (
bool
) –full_output_cov (
bool
) –
gpflow.conditionals.util.rollaxis_left#
gpflow.conditionals.util.rollaxis_right#
gpflow.conditionals.util.sample_mvn#
- gpflow.conditionals.util.sample_mvn(mean, cov, full_cov, num_samples=None)[source]#
Returns a sample from a D-dimensional Multivariate Normal distribution.
- Return type:
Tensor
- Returns:
return has shape [batch…, N, D] if num_samples is None.
return has shape [batch…, S, N, D] if num_samples is not None.
sample from the MVN
- Parameters:
mean (
Tensor
) –mean has shape [batch…, N, D].
cov (
Tensor
) –cov has shape [batch…, N, D, D] if full_cov.
cov has shape [batch…, N, D] if not full_cov.
full_cov (
bool
) –num_samples (
Optional
[int
]) –
gpflow.conditionals.util.separate_independent_conditional_implementation#
- gpflow.conditionals.util.separate_independent_conditional_implementation(Kmns, Kmms, Knns, f, *, full_cov=False, q_sqrt=None, white=False)[source]#
Multi-output GP with independent GP priors.
Number of latent processes equals the number of outputs (L = P).
Further reference:
See gpflow.conditionals._conditional for a detailed explanation of conditional in the single-output case.
See the multioutput notebook for more information about the multioutput framework.
See above for the parameters and the return value.
- Parameters:
Kmns (
Tensor
) –Kmns has shape [P, M, batch…, N].
Kmms (
Tensor
) –Kmms has shape [P, M, M].
Knns (
Tensor
) –Knns has shape [P, batch…, N, N] if full_cov.
Knns has shape [P, batch…, N] if not full_cov.
f (
Tensor
) –f has shape [M, P].
q_sqrt (
Optional
[Tensor
]) –q_sqrt has shape [M_R_or_R_M_M…].
full_cov (
bool
) –white (
bool
) –
- Return type:
Tuple
[Tensor
,Tensor
]- Returns:
return[0] has shape [batch…, N, R].
return[1] has shape [batch…, N, R] if not full_cov.
return[1] has shape [batch…, R, N, N] if full_cov.