class gpr::RFFModel

Overview

Random Fourier Features (RFF) approximation to the SE kernel. More…

#include <gpr/ml/RFFModel.h>
 
class RFFModel {
public:
    // enums
 
    enum NormalEquationBackend;
 
    // construction
 
    RFFModel();
    RFFModel(std::shared_ptr<const linalg::MpiCommunicator> communication);
 
    // methods
 
    void build(SexpatCF& kernel, const AtomsConfiguration& conf_info, const Observation& training_data, int D_rff, double noise_var = 1e-6, double grad_noise_var = 1e-4);
    void calculatePotential(Observation& image) const;
    void calculateVariance(Observation& image) const;
    bool meanHessianVector(const Eigen::VectorXd& x, const Eigen::VectorXd& v, Eigen::VectorXd& action) const;
    bool isBuilt() const;
    NormalEquationBackend normalEquationBackend() const;
    const char* normalEquationBackendName() const;
};

Detailed Documentation

Random Fourier Features (RFF) approximation to the SE kernel.

Approximates the SexpatCF kernel with D_rff random cosine features, then solves Bayesian linear regression in the feature space. Training cost is O(N * D * D_rff + D_rff^3), prediction is O(D_rff * D) per test point compared to O((N*(D+1))^3) for exact GP.

The spectral density of the SE kernel with effective variance 1/(2*l^2) per feature is N(0, 2/l^2). Per-pairtype ARD lengthscales are applied: each feature f has pairtype p(f), and W[:,f] ~ N(0, 2/l_p^2).

Workflow:

  1. Train exact GP on subset to optimize hyperparameters

  2. Call build() with trained kernel and all training data

  3. Call calculatePotential() / calculateVariance() for prediction

Note

The factor-of-2 convention: dist_at computes d = sqrt(sum 2*s2*delta^2), and the kernel is k = sigma^2 * exp(-0.5*d^2). Expanding: k = sigma^2 * exp(-sum s2*delta^2) where s2 = 1/l^2. This is an SE kernel with effective variance 1/(2*l^2) per feature, so the spectral density is N(0, 2*s2*I) = N(0, 2/l^2 * I).

See also:

InverseDistanceDescriptor for the feature map from Cartesian coordinates to inverse distances.

SexpatCF for the exact kernel this approximates.

Methods

void build(SexpatCF& kernel, const AtomsConfiguration& conf_info, const Observation& training_data, int D_rff, double noise_var = 1e-6, double grad_noise_var = 1e-4)

Build the RFF model from trained hyperparameters and data.

Parameters:

kernel

Trained SexpatCF with optimized magnSigma2 and lengthScale values.

conf_info

Configuration argument retained for callers. The kernel configuration defines the descriptor and its reference chart.

training_data

All training observations (R, E, G).

D_rff

Number of random features.

noise_var

Energy-channel noise variance for each joint observation.

grad_noise_var

Gradient-channel noise variance for each joint observation.

void calculatePotential(Observation& image) const

Predict energy and gradient at test configurations.

Fills image.E and image.G from the RFF model.

Parameters:

image

Observation with R set; E and G are filled.

void calculateVariance(Observation& image) const

Predict energy/gradient variance at test configurations.

Fills image.E and image.G with predictive variances.

Parameters:

image

Observation with R set; E and G filled with variances.

bool meanHessianVector(const Eigen::VectorXd& x, const Eigen::VectorXd& v, Eigen::VectorXd& action) const

Exact Hessian of the predicted energy at x applied to v.

Differentiates calculatePotential’s mean twice: the cosine features through the descriptor Jacobian, plus the descriptor curvature along v weighted by the feature gradient. False before build() or for a shape mismatch.