Skip to content

Basis Functions

gpjax.kernels.computations.basis_functions

Kernel = tp.TypeVar('Kernel', bound='gpjax.kernels.base.AbstractKernel') module-attribute
BasisFunctionComputation dataclass

Bases: AbstractKernelComputation

Compute engine class for finite basis function approximations to a kernel.

diagonal(kernel: Kernel, inputs: Num[Array, 'N D']) -> Diagonal

For a given kernel, compute the elementwise diagonal of the NxN gram matrix on an input matrix of shape NxD.

Parameters:

Name Type Description Default
kernel AbstractKernel

the kernel function.

required
inputs Float[Array, 'N D']

The input matrix.

required
Returns
Diagonal: The computed diagonal variance entries.
__init__() -> None
cross_covariance(kernel: Kernel, x: Float[Array, 'N D'], y: Float[Array, 'M D']) -> Float[Array, 'N M']

Compute an approximate cross-covariance matrix.

For a pair of inputs, compute the cross covariance matrix between the inputs.

Parameters:

Name Type Description Default
kernel Kernel

the kernel function.

required
x Float[Array, 'N D']

(Float[Array, "N D"]): A NΓ—DN \times D array of inputs.

required
y Float[Array, 'M D']

(Float[Array, "M D"]): A MΓ—DM \times D array of inputs.

required

Returns:

Type Description
Float[Array, 'N M']

Float[Array, "N M"]: A $N \times M$ array of cross-covariances.

gram(kernel: Kernel, inputs: Float[Array, 'N D']) -> LinearOperator

Compute an approximate Gram matrix.

For the Gram matrix, we can save computations by computing only one matrix multiplication between the inputs and the scaled frequencies.

Parameters:

Name Type Description Default
kernel Kernel

the kernel function.

required
inputs Float[Array, 'N D']

A NxDN x D array of inputs.

required

Returns:

Name Type Description
LinearOperator LinearOperator

A dense linear operator representing the NΓ—NN \times N Gram matrix.

compute_features(kernel: Kernel, x: Float[Array, 'N D']) -> Float[Array, 'N L']

Compute the features for the inputs.

Parameters:

Name Type Description Default
kernel Kernel

the kernel function.

required
x Float[Array, 'N D']

A NΓ—DN \times D array of inputs.

required
Returns
Float[Array, "N L"]: A NΓ—LN \times L array of features where L=2ML = 2M.
scaling(kernel: Kernel)

Compute the scaling factor for the covariance matrix.

Parameters:

Name Type Description Default
kernel Kernel

the kernel function.

required
Returns
Float[Array, ""]: A scalar array.