gpflow.utilities.ops

gpflow.utilities.ops.broadcasting_elementwise

gpflow.utilities.ops.broadcasting_elementwise(op, a, b)[source]

Apply binary operation op to every pair in tensors a and b.

Parameters
  • op – binary operator on tensors, e.g. tf.add, tf.substract

  • a – tf.Tensor, shape [n_1, …, n_a]

  • b – tf.Tensor, shape [m_1, …, m_b]

Returns

tf.Tensor, shape [n_1, …, n_a, m_1, …, m_b]

gpflow.utilities.ops.cast

gpflow.utilities.ops.cast(value: Union[tensorflow.Tensor, numpy.ndarray], dtype: tensorflow.DType, name: Union[str, NoneType] = None) → tensorflow.Tensor[source]
Parameters
  • value (Union[tensorflow.Tensor, ndarray]) –

  • dtype (tensorflow.DType) –

  • name (Optional[str]) –

Return type

tensorflow.Tensor

gpflow.utilities.ops.difference_matrix

gpflow.utilities.ops.difference_matrix(X, X2)[source]

Returns (X - X2ᵀ)

This function can deal with leading dimensions in X and X2. For example, If X has shape [M, D] and X2 has shape [N, D], the output will have shape [M, N, D]. If X has shape [I, J, M, D] and X2 has shape [K, L, N, D], the output will have shape [I, J, M, K, L, N, D].

gpflow.utilities.ops.eye

gpflow.utilities.ops.eye(num: int, value: tensorflow.Tensor, dtype: Union[tensorflow.DType, NoneType] = None) → tensorflow.Tensor[source]
Parameters
  • num (int) –

  • value (tensorflow.Tensor) –

  • dtype (Optional[tensorflow.DType]) –

Return type

tensorflow.Tensor

gpflow.utilities.ops.pca_reduce

gpflow.utilities.ops.pca_reduce(X: tensorflow.Tensor, latent_dim: tensorflow.Tensor) → tensorflow.Tensor[source]

A helpful function for linearly reducing the dimensionality of the input points X to latent_dim dimensions.

Parameters
  • X (tensorflow.Tensor) – data array of size N (number of points) x D (dimensions)

  • latent_dim (tensorflow.Tensor) – Number of latent dimensions Q < D

Return type

tensorflow.Tensor

Returns

PCA projection array of size [N, Q].

gpflow.utilities.ops.square_distance

gpflow.utilities.ops.square_distance(X, X2)[source]

Returns ||X - X2ᵀ||² Due to the implementation and floating-point imprecision, the result may actually be very slightly negative for entries very close to each other.

This function can deal with leading dimensions in X and X2. In the sample case, where X and X2 are both 2 dimensional, for example, X is [N, D] and X2 is [M, D], then a tensor of shape [N, M] is returned. If X is [N1, S1, D] and X2 is [N2, S2, D] then the output will be [N1, S1, N2, S2].