Skip to content

Base

AbstractKernelComputation

Abstract class for kernel computations.

This class defines the interface for computing the covariance matrix of a kernel function. It is used to compute the Gram matrix, cross-covariance, and diagonal variance of a kernel function. Each computation engine implements the computation of these quantities in a different way. Subclasses implement computations as private methods. If a non-standard interface is required, the subclass should override the public methods of this class.

gram

gram(kernel, x)

For a given kernel, compute Gram covariance operator of the kernel function on an input matrix of shape (N, D).

Parameters:

  • kernel (K) –

    the kernel function.

  • x (Num[Array, 'N D']) –

    the inputs to the kernel function of shape (N, D).

Returns:

  • Dense –

    The Gram covariance of the kernel function as a linear operator.

cross_covariance

cross_covariance(kernel, x, y)

For a given kernel, compute the cross-covariance matrix on an a pair of input matrices with shape (N, D) and (M, D).

Parameters:

  • kernel (K) –

    the kernel function.

  • x (Num[Array, 'N D']) –

    the first input matrix of shape (N, D).

  • y (Num[Array, 'M D']) –

    the second input matrix of shape (M, D).

Returns:

  • Float[Array, 'N M'] –

    The computed cross-covariance of shape (N, M).

diagonal

diagonal(kernel, inputs)

For a given kernel, compute the elementwise diagonal of the NxN gram matrix on an input matrix of shape (N, D).

Parameters:

  • kernel (K) –

    the kernel function.

  • inputs (Num[Array, 'N D']) –

    the input matrix of shape (N, D).

Returns:

  • Diagonal –

    The computed diagonal variance as a Diagonal linear operator.