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.
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 array of inputs. |
required |
y |
Float[Array, 'M D']
|
(Float[Array, "M D"]): A 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 array of inputs. |
required |
Returns:
Name | Type | Description |
---|---|---|
LinearOperator |
LinearOperator
|
A dense linear operator representing the Gram matrix. |
compute_features(kernel: Kernel, x: Float[Array, 'N D']) -> Float[Array, 'N L']
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.