gpytorch.kernels.keops

These kernels are compatible with the GPyTorch KeOps integration. For more information, see the KeOps tutorial.

Note

Only some standard kernels have KeOps impementations. If there is a kernel you want that’s missing, consider submitting a pull request!

RBFKernel

class gpytorch.kernels.keops.RBFKernel(ard_num_dims=None, batch_shape=None, active_dims=None, lengthscale_prior=None, lengthscale_constraint=None, eps=1e-06, **kwargs)[source]

Implements the RBF kernel using KeOps as a driver for kernel matrix multiplies.

This class can be used as a drop in replacement for gpytorch.kernels.RBFKernel in most cases, and supports the same arguments.

Parameters:
  • ard_num_dims (int, optional) – Set this if you want a separate lengthscale for each input dimension. It should be d if x1 is a n x d matrix. (Default: None.)

  • batch_shape (torch.Size, optional) – Set this if you want a separate lengthscale for each batch of input data. It should be \(B_1 \times \ldots \times B_k\) if \(\mathbf x1\) is a \(B_1 \times \ldots \times B_k \times N \times D\) tensor.

  • active_dims ((int, ...), optional) – Set this if you want to compute the covariance of only a few input dimensions. The ints corresponds to the indices of the dimensions. (Default: None.)

  • lengthscale_prior (Prior, optional) – Set this if you want to apply a prior to the lengthscale parameter. (Default: None)

  • lengthscale_constraint (Interval, optional) – Set this if you want to apply a constraint to the lengthscale parameter. (Default: Positive.)

  • eps (float) – The minimum value that the lengthscale can take (prevents divide by zero errors). (Default: 1e-6.)

Variables:

lengthscale (torch.Tensor) – The lengthscale parameter. Size/shape of parameter depends on the ard_num_dims and batch_shape arguments.

MaternKernel

class gpytorch.kernels.keops.MaternKernel(nu=2.5, **kwargs)[source]

Implements the Matern kernel using KeOps as a driver for kernel matrix multiplies.

This class can be used as a drop in replacement for gpytorch.kernels.MaternKernel in most cases, and supports the same arguments.

Parameters:
  • nu (float (0.5, 1.5, or 2.5)) – (Default: 2.5) The smoothness parameter.

  • ard_num_dims (int, optional) – (Default: None) Set this if you want a separate lengthscale for each input dimension. It should be d if x1 is a … x n x d matrix.

  • batch_shape (torch.Size, optional) – (Default: None) Set this if you want a separate lengthscale for each batch of input data. It should be torch.Size([b1, b2]) for a b1 x b2 x n x m kernel output.

  • active_dims (Tuple(int)) – (Default: None) Set this if you want to compute the covariance of only a few input dimensions. The ints corresponds to the indices of the dimensions.

  • lengthscale_prior (Prior, optional) – (Default: None) Set this if you want to apply a prior to the lengthscale parameter.

  • lengthscale_constraint (Interval, optional) – (Default: Positive) Set this if you want to apply a constraint to the lengthscale parameter.

  • eps (float, optional) – (Default: 1e-6) The minimum value that the lengthscale can take (prevents divide by zero errors).

PeriodicKernel

class gpytorch.kernels.keops.PeriodicKernel(period_length_prior=None, period_length_constraint=None, **kwargs)[source]

Implements the Periodic Kernel using KeOps as a driver for kernel matrix multiplies.

This class can be used as a drop in replacement for gpytorch.kernels.PeriodicKernel in most cases, and supports the same arguments.

Parameters:
  • ard_num_dims (int, optional) – (Default: None) Set this if you want a separate lengthscale for each input dimension. It should be d if x1 is a … x n x d matrix.

  • batch_shape (torch.Size, optional) – (Default: None) Set this if you want a separate lengthscale for each batch of input data. It should be torch.Size([b1, b2]) for a b1 x b2 x n x m kernel output.

  • active_dims (Tuple(int)) – (Default: None) Set this if you want to compute the covariance of only a few input dimensions. The ints corresponds to the indices of the dimensions.

  • period_length_prior (Prior, optional) – (Default: None) Set this if you want to apply a prior to the period length parameter.

  • period_length_constraint (Interval, optional) – (Default: Positive) Set this if you want to apply a constraint to the period length parameter.

  • lengthscale_prior (Prior, optional) – (Default: None) Set this if you want to apply a prior to the lengthscale parameter.

  • lengthscale_constraint (Interval, optional) – (Default: Positive) Set this if you want to apply a constraint to the lengthscale parameter.

  • eps (float, optional) – (Default: 1e-6) The minimum value that the lengthscale can take (prevents divide by zero errors).

Variables:

period_length (torch.Tensor) – The period length parameter. Size/shape of parameter depends on the ard_num_dims and batch_shape arguments.