gpflow.conditionals.util

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 – has shape [N, P] (full_cov = False) or [P, N, N] (full_cov = True).

Returns

  1. full_cov: True and full_output_cov: True fvar [N, P, N, P]

  2. full_cov: True and full_output_cov: False fvar [P, N, N]

  3. full_cov: False and full_output_cov: True fvar [N, P, P]

  4. full_cov: False and full_output_cov: False fvar [N, P]

gpflow.conditionals.util.fully_correlated_conditional

gpflow.conditionals.util.fully_correlated_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False)[source]

This function handles conditioning of multi-output GPs in the case where the conditioning points are all fully correlated, in both the prior and posterior. :param Kmn: [M, N, P] :param Kmm: [M, M] :param Knn: [N, P] or [N, P, N, P] :param f: data matrix, [M, 1] :param q_sqrt: [1, M, M] or [1, L] :param full_cov: calculate covariance between inputs :param full_output_cov: calculate covariance between outputs :param white: use whitened representation :return:

  • mean: [N, P]

  • variance: [N, P], [N, P, P], [P, N, N], [N, P, N, P]

gpflow.conditionals.util.fully_correlated_conditional_repeat

gpflow.conditionals.util.fully_correlated_conditional_repeat(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False)[source]

This function handles conditioning of multi-output GPs in the case where the conditioning points are all fully correlated, in both the prior and posterior. Note: This conditional can handle ‘repetitions’ R, given in f and q_sqrt. :param Kmn: [M, N, P] :param Kmm: [M, M] :param Knn: [N, P] or [N, P, P] or [P, N, N] or [N, P, N, P] :param f: data matrix, [M, R] :param q_sqrt: [R, M, M] or [M, R] :param full_cov: calculate covariance between inputs :param full_output_cov: calculate covariance between outputs :param white: use whitened representation :return:

  • mean: [R, N, P]

  • variance: [R, N, P], [R, N, P, P], [R, P, N, N], [R, N, P, N, P]

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. :param Kmn: [M, L, N, P] :param Kmm: [L, M, M] :param Knn: [N, P] or [N, P, P] or [P, N, N] or [N, P, N, P] :param f: data matrix, [M, L] :param q_sqrt: [L, M, M] or [M, L] :param full_cov: calculate covariance between inputs :param full_output_cov: calculate covariance between outputs :param white: use whitened representation :return:

  • mean: [N, P]

  • variance: [N, P], [N, P, P], [P, N, N], [N, P, N, P]

gpflow.conditionals.util.leading_transpose

gpflow.conditionals.util.leading_transpose(tensor: tensorflow.Tensor, perm: List[Union[int, ellipsis]], leading_dim: int = 0) → tensorflow.Tensor[source]

Transposes tensors with leading dimensions. Leading dimensions in permutation list represented via ellipsis . When leading dimensions are found, transpose method considers them as a single grouped element indexed by 0 in perm list. So, passing perm=[-2, …, -1], you assume that your input tensor has […, A, B] shape, and you want to move leading dims between A and B dimensions. Dimension indices in permutation list can be negative or positive. Valid positive indices start from 1 up to the tensor rank, viewing leading dimensions as zero index. Example:

a = tf.random.normal((1, 2, 3, 4, 5, 6))

# […, A, B, C], # where A is 1st element, # B is 2nd element and # C is 3rd element in # permutation list, # leading dimensions are [1, 2, 3] # which are 0th element in permutation # list

b = leading_transpose(a, [3, -3, …, -2]) # [C, A, …, B] sess.run(b).shape output> (6, 4, 1, 2, 3, 5)

Parameters
  • tensor (tensorflow.Tensor) – TensorFlow tensor.

  • perm (List[Union[int, ellipsis]]) – List of permutation indices.

Return type

tensorflow.Tensor

Returns

TensorFlow tensor.

Raises

ValueError when cannot be found.

Parameters

leading_dim (int) –

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, with W having a shape [P, L]

Parameters
  • W – [P, L]

  • g_mean – […, N, L]

  • g_var – […, N, L] (full_cov = False) or [L, …, N, N] (full_cov = True)

Returns

f_mean and f_var, shape depends on full_cov and full_output_cov

gpflow.conditionals.util.rollaxis_left

gpflow.conditionals.util.rollaxis_left(A, num_rolls)[source]

Roll the tensor A backwards num_rolls times.

gpflow.conditionals.util.rollaxis_right

gpflow.conditionals.util.rollaxis_right(A, num_rolls)[source]

Roll the tensor A forward num_rolls times.

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 :param mean: […, N, D] :param cov: […, N, D] or […, N, D, D] :param full_cov: if True return a “full” covariance matrix, otherwise a “diag”: - “full”: cov holds the full covariance matrix (without jitter) - “diag”: cov holds the diagonal elements of the covariance matrix :return: sample from the MVN of shape […, (S), N, D], S = num_samples