GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
RandomFourierFeatures.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
// See LICENSE for details.
4
17
18
#ifndef GPR_ML_RANDOMFOURIERFEATURES_H_
19
#define GPR_ML_RANDOMFOURIERFEATURES_H_
20
21
#include <Eigen/Dense>
22
23
#include "
../../backend/Macros.h
"
24
25
namespace
gpr
{
26
36
class
RandomFourierFeatures
{
37
public
:
46
RandomFourierFeatures
(
int
n_features,
double
lengthscale
,
int
input_dim,
47
int
seed = 42);
48
55
void
setLengthscale
(
double
l);
56
63
Eigen::VectorXd
transform
(
const
Eigen::VectorXd&
x
)
const
;
64
71
EigenMatrix
transformBatch
(
const
EigenMatrix
& X)
const
;
72
79
EigenMatrix
approximateKernel
(
const
EigenMatrix
& X)
const
;
80
81
int
nFeatures
()
const
82
{
83
return
n_features_;
84
}
85
int
inputDim
()
const
86
{
87
return
input_dim_;
88
}
89
double
lengthscale
()
const
90
{
91
return
lengthscale_;
92
}
93
94
private
:
95
void
generateWeights();
96
97
int
n_features_;
98
double
lengthscale_;
99
int
input_dim_;
100
int
seed_;
101
102
EigenMatrix
W_;
// (n_features x input_dim)
103
Eigen::VectorXd b_;
// (n_features)
104
double
scale_factor_;
// sqrt(2 / n_features)
105
};
106
107
}
// namespace gpr
108
109
#endif
// GPR_ML_RANDOMFOURIERFEATURES_H_
x
@ x
Definition
Enums.h:28
Macros.h
gpr::RandomFourierFeatures::setLengthscale
void setLengthscale(double l)
Change the lengthscale and regenerate random weights.
Definition
RandomFourierFeatures.cpp:25
gpr::RandomFourierFeatures::lengthscale
double lengthscale() const
Definition
RandomFourierFeatures.h:89
gpr::RandomFourierFeatures::inputDim
int inputDim() const
Definition
RandomFourierFeatures.h:85
gpr::RandomFourierFeatures::nFeatures
int nFeatures() const
Definition
RandomFourierFeatures.h:81
gpr::RandomFourierFeatures::transformBatch
EigenMatrix transformBatch(const EigenMatrix &X) const
Compute feature vectors for all rows of X.
Definition
RandomFourierFeatures.cpp:57
gpr::RandomFourierFeatures::RandomFourierFeatures
RandomFourierFeatures(int n_features, double lengthscale, int input_dim, int seed=42)
Construct and initialize RFF weights from a seeded RNG.
Definition
RandomFourierFeatures.cpp:12
gpr::RandomFourierFeatures::transform
Eigen::VectorXd transform(const Eigen::VectorXd &x) const
Compute the feature vector phi(x) for a single input.
Definition
RandomFourierFeatures.cpp:50
gpr::RandomFourierFeatures::approximateKernel
EigenMatrix approximateKernel(const EigenMatrix &X) const
Approximate the kernel matrix K ~ Phi * Phi^T.
Definition
RandomFourierFeatures.cpp:66
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr::EigenMatrix
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition
Macros.h:20
gpr
ml
RandomFourierFeatures.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf