geometric_kernels.feature_maps.rejection_sampling

This module provides the RejectionSamplingFeatureMapHyperbolic and the RejectionSamplingFeatureMapSPD, rejection sampling-based feature maps for Hyperbolic and SymmetricPositiveDefiniteMatrices, respectively.

Module Contents

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

Bases: geometric_kernels.feature_maps.base.FeatureMap

Random phase feature map for the Hyperbolic space based on the rejection sampling algorithm.

Parameters:
  • space (geometric_kernels.spaces.Hyperbolic) – A Hyperbolic 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, D] 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]

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

Bases: geometric_kernels.feature_maps.base.FeatureMap

Random phase feature map for the SymmetricPositiveDefiniteMatrices space based on the rejection sampling algorithm.

Parameters:
__call__(X, params, *, key, normalize=True, **kwargs)[source]
Parameters:
  • X (lab.Numeric) – [N, D, D] 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]