geometric_kernels.feature_maps.rejection_sampling ================================================= .. py:module:: geometric_kernels.feature_maps.rejection_sampling .. autoapi-nested-parse:: This module provides the :class:`RejectionSamplingFeatureMapHyperbolic` and the :class:`RejectionSamplingFeatureMapSPD`, rejection sampling-based feature maps for :class:`~.spaces.Hyperbolic` and :class:`~.spaces.SymmetricPositiveDefiniteMatrices`, respectively. Module Contents --------------- .. py:class:: RejectionSamplingFeatureMapHyperbolic(space, num_random_phases = 3000, shifted_laplacian = True) Bases: :py:obj:`geometric_kernels.feature_maps.base.FeatureMap` Random phase feature map for the :class:`~.spaces.Hyperbolic` space based on the rejection sampling algorithm. :param space: A :class:`~.spaces.Hyperbolic` space. :param num_random_phases: Number of random phases to use. :param shifted_laplacian: 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. .. py:method:: __call__(X, params, *, key, normalize = True, **kwargs) :param X: [N, D] points in the space to evaluate the map on. :param params: Parameters of the feature map (length scale and smoothness). :param key: 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 :func:`~.utils.make_deterministic` which does this for you. :param normalize: Normalize to have unit average variance (`True` by default). :param ``**kwargs``: Unused. :return: `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. .. py:class:: RejectionSamplingFeatureMapSPD(space, num_random_phases = 3000, shifted_laplacian = True) Bases: :py:obj:`geometric_kernels.feature_maps.base.FeatureMap` Random phase feature map for the :class:`~.spaces.SymmetricPositiveDefiniteMatrices` space based on the rejection sampling algorithm. :param space: A :class:`~.spaces.SymmetricPositiveDefiniteMatrices` space. :param num_random_phases: Number of random phases to use. :param shifted_laplacian: 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. .. py:method:: __call__(X, params, *, key, normalize = True, **kwargs) :param X: [N, D, D] points in the space to evaluate the map on. :param params: Parameters of the feature map (length scale and smoothness). :param key: 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 :func:`~.utils.make_deterministic` which does this for you. :param normalize: Normalize to have unit average variance (`True` by default). :param ``**kwargs``: Unused. :return: `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.