gpflux.layers.basis_functions.fourier_features.quadrature.gaussian#

Kernel decompositon into features and coefficients based on Gauss-Christoffel quadrature aka Gaussian quadrature.

Module Contents#

class FourierFeaturesBase(kernel: gpflow.kernels.Kernel, n_components: int, **kwargs: Mapping)[source]#

Bases: abc.ABC, gpflow.keras.tf_keras.layers.Layer

The base class for all Fourier feature layers, used for both random Fourier feature layers and quadrature layers. We subclass tf.keras.layers.Layer, so we must provide :method:`build` and :method:`call` methods.

Parameters:
  • kernel – kernel to approximate using a set of Fourier bases.

  • n_components – number of components (e.g. Monte Carlo samples, quadrature nodes, etc.) used to numerically approximate the kernel.

call(inputs: gpflow.base.TensorType) tf.Tensor[source]#

Evaluate the basis functions at inputs.

Parameters:

inputs – The evaluation points, a tensor with the shape [N, D].

Returns:

A tensor with the shape [N, M], or shape ``[P, N, M]’’ in the multioutput case.

compute_output_shape(input_shape: gpflux.types.ShapeType) tf.TensorShape[source]#

Computes the output shape of the layer. See tf.keras.layers.Layer.compute_output_shape().

get_config() Mapping[source]#

Returns the config of the layer. See tf.keras.layers.Layer.get_config().

abstract _compute_constant() tf.Tensor[source]#

Compute normalizing constant for basis functions.

abstract _compute_bases(inputs: gpflow.base.TensorType) tf.Tensor[source]#

Compute basis functions.

_bases_concat(X: gpflow.base.TensorType, W: gpflow.base.TensorType) gpflow.base.TensorType[source]#

Feature map for random Fourier features (RFF) as originally prescribed by Rahimi & Recht, 2007 [RR07]. See also [SS15] for additional details.

ShapeType[source]#

Union of valid types for describing the shape of a tf.Tensor(-like) object

class QuadratureFourierFeatures(kernel: gpflow.kernels.Kernel, n_components: int, **kwargs: Mapping)[source]#

Bases: gpflux.layers.basis_functions.fourier_features.base.FourierFeaturesBase

The base class for all Fourier feature layers, used for both random Fourier feature layers and quadrature layers. We subclass tf.keras.layers.Layer, so we must provide :method:`build` and :method:`call` methods.

Parameters:
  • kernel – kernel to approximate using a set of Fourier bases.

  • n_components – number of components (e.g. Monte Carlo samples, quadrature nodes, etc.) used to numerically approximate the kernel.

build(input_shape: gpflux.types.ShapeType) None[source]#

Creates the variables of the layer. See tf.keras.layers.Layer.build().

_compute_bases(inputs: gpflow.base.TensorType) tf.Tensor[source]#

Compute basis functions.

Returns:

A tensor with the shape [N, 2M^D].

_compute_constant() tf.Tensor[source]#

Compute normalizing constant for basis functions.

Returns:

A tensor with the shape [2M^D,]