geometric_kernels.feature_maps.random_phase

This module provides the random phase-based feature maps.

Specifically, it provides a random phase-based feature map for DiscreteSpectrumSpaces for which the addition theorem-like basis functions are explicitly available while the actual eigenpairs may remain implicit.

It also provides a basic random phase-based feature map for NoncompactSymmetricSpaces. It should be used unless a more specialized per-space implementation is available, like the ones in the module geometric_kernels.feature_maps.rejection_sampling.

Module Contents

class geometric_kernels.feature_maps.random_phase.RandomPhaseFeatureMapCompact(space, num_levels, num_random_phases=3000)[source]

Bases: geometric_kernels.feature_maps.base.FeatureMap

Random phase feature map for DiscreteSpectrumSpaces for which the addition theorem-like basis functions are explicitly available while actual eigenpairs may be implicit.

Parameters:
__call__(X, params, *, key, normalize=None, **kwargs)[source]
Parameters:
  • X (lab.Numeric) – [N, …] points in the space to evaluate the map on.

  • params (beartype.typing.Dict[str, lab.Numeric]) – Parameters of the kernel (length scale and smoothness).

  • key (lab.RandomState) –

    Random state, either np.random.RandomState, tf.random.Generator, torch.Generator or jax.tensor (which represents a random state).

    Note

    For any backend other than jax, passing the same key twice does not guarantee that the feature map will be the same each time. This is because these backends’ random state has… a state. To evaluate the same (including randomness) feature map on different inputs, you can either save/restore state manually each time or use the helper function make_deterministic() which does this for you.

  • normalize (beartype.typing.Optional[bool]) – Normalize to have unit average variance (if omitted or None, follows the standard behavior of kernels.MaternKarhunenLoeveKernel).

  • **kwargs – Unused.

Returns:

Tuple(key, features) where features is an [N, O] array, N is the number of inputs and O is the dimension of the feature map; key is the updated random key for jax, or the similar random state (generator) for any other backends.

Return type:

beartype.typing.Tuple[lab.RandomState, lab.Numeric]

class geometric_kernels.feature_maps.random_phase.RandomPhaseFeatureMapNoncompact(space, num_random_phases=3000, shifted_laplacian=True)[source]

Bases: geometric_kernels.feature_maps.base.FeatureMap

Basic random phase feature map for NoncompactSymmetricSpaces (importance sampling based).

This feature map should not be used if a space-specific alternative exists.

Parameters:
  • space (geometric_kernels.spaces.NoncompactSymmetricSpace) – A NoncompactSymmetricSpace space.

  • num_random_phases (int) – Number of random phases to use.

  • shifted_laplacian (bool) –

    If True, assumes that the kernels are defined in terms of the shifted Laplacian. This often makes Matérn kernels more flexible by widening the effective range of the length scale parameter.

    Defaults to True.

__call__(X, params, *, key, normalize=True, **kwargs)[source]
Parameters:
  • X (lab.Numeric) – [N, …] points in the space to evaluate the map on.

  • params (beartype.typing.Dict[str, lab.Numeric]) – Parameters of the feature map (length scale and smoothness).

  • key (lab.RandomState) –

    Random state, either np.random.RandomState, tf.random.Generator, torch.Generator or jax.tensor (which represents a random state).

    Note

    For any backend other than jax, passing the same key twice does not guarantee that the feature map will be the same each time. This is because these backends’ random state has… a state. To evaluate the same (including randomness) feature map on different inputs, you can either save/restore state manually each time or use the helper function make_deterministic() which does this for you.

  • normalize (beartype.typing.Optional[bool]) – Normalize to have unit average variance (True by default).

  • **kwargs – Unused.

Returns:

Tuple(key, features) where features is an [N, O] array, N is the number of inputs and O is the dimension of the feature map; key is the updated random key for jax, or the similar random state (generator) for any other backends.

Return type:

beartype.typing.Tuple[lab.RandomState, lab.Numeric]