dmgp.kernels

If you don’t know what kernel to use, we recommend that you start out with a dmgp.kernels.LaplaceProductKernel().

Laplace Kernels

LaplaceProductKernel

class dmgp.kernels.LaplaceProductKernel(lengthscale=None)[source]

Computes a covariance matrix based on the Laplace product kernel between inputs \(\mathbf{x_1}\) and \(\mathbf{x_2}\):

\[\begin{equation*} k\left( \mathbf{x_1}, \mathbf{x_2} \right) = \exp\left\{ -\frac{\left\| \mathbf{x_1}- \mathbf{x_2} \right\|_1}{\theta} \right\} \end{equation*}\]

where \(\theta\) is the lengthscale parameter.

Parameters:

lengthscale (float, optional) – Set this if you want a customized lengthscale. It should be a tensor of size (d,). (Default: 1.0.)

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

Computes the covariance between \(\mathbf x_1\) and \(\mathbf x_2\).

Parameters:
  • x1 (torch.Tensor.float) – First set of data of shape \((n,d)\).

  • x2 (torch.Tensor.float) – Second set of data of shape \((m,d)\).

  • diag (bool, optional) – Compute diagonal covariance matrix if True. It must be the case that x1 == x2. Default: False.

Return type:

Tensor

Returns:

The kernel matrix or vector. The shape depends on the kernel’s mode: * ‘full_cov`: n x m * diag: n

LaplaceAdditiveKernel

class dmgp.kernels.LaplaceAdditiveKernel(lengthscale=None)[source]

Computes a covariance matrix based on the Laplace additive kernel between inputs \(\mathbf{x_1}\) and \(\mathbf{x_2}\):

\[\begin{equation*} k\left( \mathbf{x_1}, \mathbf{x_2} \right) = \sum_{j=1}^{d}\exp\left\{ -\frac{\left( x_{1,j}- x_{2,j} \right)}{\theta} \right\} \end{equation*}\]

where \(\theta\) is the lengthscale parameter.

Parameters:

lengthscale (float, optional) – Set this if you want a customized lengthscale. It should be a tensor of size (d,). (Default: 1.0.)

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

Computes the covariance between \(\mathbf x_1\) and \(\mathbf x_2\).

Parameters:
  • x1 (torch.Tensor.float) – First set of data of shape \((n,d)\).

  • x2 (torch.Tensor.float) – Second set of data of shape \((m,d)\).

  • diag (bool, optional) – Compute diagonal covariance matrix if True. It must be the case that x1 == x2. Default: False.

Return type:

Tensor

Returns:

The kernel matrix or vector. The shape depends on the kernel’s mode: * ‘full_cov`: n x m * diag: n