grf_gp.kernels.base module

class grf_gp.kernels.base.BaseExactKernel(ard_num_dims: int | None = None, batch_shape: Size | None = None, active_dims: tuple[int, ...] | None = None, lengthscale_prior: Prior | None = None, lengthscale_constraint: Interval | None = None, **kwargs)

Bases: Kernel, ABC

Base class for exact graph kernels defined by a full kernel matrix.

forward(x1, x2, diag=False, **kwargs)

Extract entries from the full kernel matrix.

Parameters:
  • x1 – Row indices for the first argument.

  • x2 – Row indices for the second argument.

  • diag – Whether to return diagonal entries only.

  • kwargs – Additional unused keyword arguments.

Returns:

Kernel matrix block or diagonal extracted from the full matrix.

class grf_gp.kernels.base.BaseGRFKernel(rw_mats, **kwargs)

Bases: Kernel, ABC

Base class for GRF kernels defined through random-walk features.

forward(x1_idx=None, x2_idx=None, diag=False, **params)

Evaluate kernel entries using the GRF feature matrix.

Efficient implementation of \(K[x_1, x_2]\), where \(K = \Phi \Phi^ op\).

Parameters:
  • x1_idx – Row indices for the first argument.

  • x2_idx – Row indices for the second argument.

  • diag – Whether to return only the diagonal entries.

  • params – Additional keyword arguments accepted by the kernel API.

Returns:

Kernel matrix block or diagonal extracted from \(K\).

abstract property modulation_function: Tensor

Return the modulation coefficients applied to the walk matrices.

Returns:

Modulation vector indexed by walk length.