OrthogonalRFF

class franken.rf.heads.OrthogonalRFF(input_dim, num_random_features=2**10, num_species=None, chemically_informed_ratio=None, use_offset=True, length_scale=1.0, rng_seed=None)

Bases: RandomFeaturesHead

Orthogonal Random Fourier Features by Yu et al. for approximating the Gaussian kernel

\[\text{exp}\left(-\frac{\| x - y \|^{2}}{2\ell^{2}}\right)\]

As with the Gaussian kernel, the RF approximation depends on the length_scale parameter. In addition to that, one needs to choose the number of random features to control the approximation quality.

Parameters:
  • input_dim (int) – Dimensionality of the input features.

  • num_random_features (int) – The number of random features to use in the feature mapping. Defaults to \(2^{10} = 1024\).

  • num_species (int | None) – The number of chemical species for which the kernel is computed. This parameter is relevant for systems with multiple chemical species. Defaults to None.

  • chemically_informed_ratio (float | None) – The relative weight of chemically-informed kernels with respect to the all-species kernel. Ignored if num_species is None. Defaults to None.

  • use_offset (bool) – A flag indicating whether to use an offset in the random feature generation. Using an offset reduces the number of random features by half but increases variance. Defaults to True.

  • length_scale (float) – The length scale parameter \(\ell\) that controls the smoothness of the kernel function. It affects how quickly the kernel values decay with distance. Defaults to 1.0.

  • rng_seed (int | None) – A seed for the random number generator used in generating random features. Setting this ensures reproducibility of results. Defaults to None.

feature_map(h, atomic_numbers=None, batch_ids=None)

Computes the random-feature map for a given configuration h

Parameters:
  • h (torch.Tensor) – descriptors for a single configuration ~[natoms, descriptors]

  • atomic_numbers (torch.Tensor) – atomic numbers for a single configuration ~[natoms]