aepsych.kernels

Submodules

aepsych.kernels.rbf_partial_grad module

Module contents

class aepsych.kernels.PairwiseKernel(latent_kernel, is_partial_obs=False, **kwargs)[source]

Bases: Kernel

Wrapper to convert a kernel K on R^k to a kernel K’ on R^{2k}, modeling functions of the form g(a, b) = f(a) - f(b), where f ~ GP(mu, K).

Since g is a linear combination of Gaussians, it follows that g ~ GP(0, K’) where K’((a,b), (c,d)) = K(a,c) - K(a, d) - K(b, c) + K(b, d).

Parameters:
  • latent_kernel (Kernel) – The underlying kernel used to compute the covariance for the GP.

  • is_partial_obs (bool) – If the kernel should handle partial observations. Defaults to False.

forward(x1, x2, diag=False, **params)[source]

TODO: make last_batch_dim work properly

d must be 2*k for integer k, k is the dimension of the latent space

Parameters:
  • x1 (torch.Tensor) – A b x n x d or n x d tensor, where d = 2k and k is the dimension of the latent space.

  • x2 (torch.Tensor) – A b x m x d or m x d tensor, where d = 2k and k is the dimension of the latent space.

  • diag (bool) – Should the Kernel compute the whole covariance matrix or just the diagonal? Defaults to False.

Returns:

A b x n x m or n x m tensor representing the covariance matrix between x1 and x2. The exact size depends on the kernel’s evaluation mode: * full_covar: n x m or b x n x m * diag: n or b x n

Return type:

torch.Tensor (or gpytorch.lazy.LazyTensor)