Graph
GraphKernel
GraphKernel(
laplacian: Num[Array, "N N"],
active_dims: Union[list[int], slice, None] = None,
lengthscale: Union[
ScalarFloat, Float[Array, " D"], AbstractUnwrappable
] = 1.0,
variance: Union[ScalarFloat, AbstractUnwrappable] = 1.0,
smoothness: ScalarFloat = 1.0,
n_dims: Union[int, None] = None,
compute_engine: AbstractKernelComputation = EigenKernelComputation(),
)
Bases: StationaryKernel
The Matérn graph kernel defined on the vertex set of a graph.
A Matérn graph kernel defined through the graph Laplacian spectrum.
The kernel evaluates a Matérn spectral filter on each Laplacian eigenvalue \(\lambda\): $$ \Phi(\lambda) = \left(\frac{2\nu}{\ell^2} + \lambda\right)^{-\nu}, $$ where \(\ell\) is the lengthscale parameter and \(\nu\) is the smoothness parameter. The resulting spectral weights are normalised and scaled by the variance parameter.
The key reference for this object is Borovitskiy et al. (2021).
Parameters:
-
laplacian(Num[Array, 'N N']) –the Laplacian matrix of the graph.
-
active_dims(Union[list[int], slice, None], default:None) –The indices of the input dimensions that the kernel operates on.
-
lengthscale(Union[ScalarFloat, Float[Array, ' D'], AbstractUnwrappable], default:1.0) –the lengthscale(s) of the kernel ℓ. If a scalar or an array of length 1, the kernel is isotropic, meaning that the same lengthscale is used for all input dimensions. If an array with length > 1, the kernel is anisotropic, meaning that a different lengthscale is used for each input.
-
variance(Union[ScalarFloat, AbstractUnwrappable], default:1.0) –the variance of the kernel σ.
-
smoothness(ScalarFloat, default:1.0) –the smoothness parameter of the Matérn kernel.
-
n_dims(Union[int, None], default:None) –The number of input dimensions. If
lengthscaleis an array, this argument is ignored. -
compute_engine(AbstractKernelComputation, default:EigenKernelComputation()) –The computation engine that the kernel uses to compute the covariance matrix.
spectral_density
property
The spectral density of the kernel.
Returns:
-
Normal | StudentT–Callable[[Float[Array, "D"]], Float[Array, "D"]]: The spectral density function.
cross_covariance
Compute the cross-covariance matrix of the kernel.
Parameters:
-
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 cross-covariance matrix of the kernel of shape
(N, M).
gram
Compute the gram matrix of the kernel.
Parameters:
-
x(Num[Array, 'N D']) –the input matrix of shape
(N, D).
Returns:
-
AbstractLinearOperator–The gram matrix of the kernel of shape
(N, N).
diagonal
Compute the diagonal of the gram matrix of the kernel.
Parameters:
-
x(Num[Array, 'N D']) –the input matrix of shape
(N, D).
Returns:
-
AbstractLinearOperator–The diagonal of the gram matrix of the kernel of shape
(N,).
slice_input
Slice out the relevant columns of the input matrix.
Select the relevant columns of the supplied matrix to be used within the kernel's evaluation.
Parameters:
-
x(Float[Array, '... D']) –the matrix or vector that is to be sliced.
Returns:
-
Float[Array, '... Q']–The sliced form of the input matrix.
__add__
Add two kernels together. Args: other (AbstractKernel): The kernel to be added to the current kernel.
Returns:
-
AbstractKernel(AbstractKernel) –A new kernel that is the sum of the two kernels.
__mul__
Multiply two kernels together.
Parameters:
-
other(AbstractKernel) –The kernel to be multiplied with the current kernel.
Returns:
-
AbstractKernel(AbstractKernel) –A new kernel that is the product of the two kernels.