RFF#

class gpjax.kernels.RFF(base_kernel, num_basis_fns=50, frequencies=None, compute_engine=<gpjax.kernels.computations.basis_functions.BasisFunctionComputation object>, key=Array((), dtype=key<fry>) overlaying: [0 0])[source]#

Bases: AbstractKernel

Computes an approximation of the kernel using Random Fourier Features.

All stationary kernels are equivalent to the Fourier transform of a probability distribution. We call the corresponding distribution the spectral density. Using a finite number of basis functions, we can compute the spectral density using a Monte-Carlo approximation. This is done by sampling from the spectral density and computing the Fourier transform of the samples. The kernel is then approximated by the inner product of the Fourier transform of the samples with the Fourier transform of the data.

The key reference for this implementation is the following papers: - ‘Random Features for Large-Scale Kernel Machines’ by Rahimi and Recht (2008). - ‘On the Error of Random Fourier Features’ by Sutherland and Schneider (2015).

Parameters:
  • base_kernel (StationaryKernel)

  • num_basis_fns (int)

  • frequencies (Float[jaxlib._jax.Array, 'M D'] | Float[ndarray, 'M D'] | None)

  • compute_engine (BasisFunctionComputation)

  • key (UInt32[jaxlib._jax.Array, '2'] | Key[jaxlib._jax.Array, ''])

compute_features(x)[source]#

Compute the features for the inputs.

Parameters:

x (Float[jaxlib._jax.Array, 'N D'] | Float[ndarray, 'N D']) – A \(N \times D\) array of inputs.

Returns:

A \(N \times L\) array of features where \(L = 2M\).

Return type:

Float[Array, “N L”]