Graph
GraphKernel
GraphKernel(
laplacian,
active_dims=None,
lengthscale=1.0,
variance=1.0,
smoothness=1.0,
n_dims=None,
compute_engine=EigenKernelComputation(),
)
Bases: StationaryKernel
The MatΓ©rn graph kernel defined on the vertex set of a graph.
A MatΓ©rn graph kernel defined on the vertices of a graph.
Computes the covariance for pairs of vertices \((v_i, v_j)\) with variance \(\sigma^2\): $$ k(v_i, v_j) = \sigma^2 \exp\Bigg(-\frac{\lVert v_i - v_j \rVert^2_2}{2\ell^2}\Bigg) $$ where \(\ell\) is the lengthscale parameter and \(\sigma^2\) is the variance.
The key reference for this object is Borovitskiy et. al., (2020).
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'], Parameter], 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, Parameter], 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:
-
LinearOperatorβ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:
-
LinearOperatorβ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.