expand_independent_outputs(fvar, full_cov, full_output_cov)¶
Reshapes fvar to the correct shape, specified by full_cov and full_output_cov.
fvar – has shape [N, P] (full_cov = False) or [P, N, N] (full_cov = True).
full_cov: True and full_output_cov: True fvar [N, P, N, P]
full_cov: True and full_output_cov: False fvar [P, N, N]
full_cov: False and full_output_cov: True fvar [N, P, P]
full_cov: False and full_output_cov: False fvar [N, P]
independent_interdomain_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False)¶
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]
leading_transpose(tensor: tensorflow.Tensor, perm: List[Union[int, ellipsis]], leading_dim: int = 0) → tensorflow.Tensor¶
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)
tensor (tensorflow.Tensor) – TensorFlow tensor.
ellipsis]]) – List of permutation indices.
- Return type
ValueError when … cannot be found.
mix_latent_gp(W, g_mean, g_var, full_cov, full_output_cov)¶
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]
W – [P, L]
g_mean – […, N, L]
g_var – […, N, L] (full_cov = False) or [L, …, N, N] (full_cov = True)
f_mean and f_var, shape depends on full_cov and full_output_cov
Roll the tensor A backwards num_rolls times.
Roll the tensor A forward num_rolls times.
sample_mvn(mean, cov, full_cov, num_samples=None)¶
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