GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
IterGP.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) gpridge developers
3
//
4
// IterGP: posterior and computational uncertainty in Gaussian processes.
5
// Wenger, Pleiss, Hennig, Cunningham, Weinberger, NeurIPS 2022,
6
// DOI 10.48550/arxiv.2205.15449.
7
//
8
// A GP whose linear solve has not converged is not a GP with a slightly wrong
9
// posterior -- it is a GP whose posterior is unknown in the directions the
10
// solver never explored. IterGP makes that explicit. After i actions
11
// S = [s_1 ... s_i] the solver has learned K^{-1} only on span(S), and the
12
// representer weights and posterior covariance are
13
//
14
// C_i = S (S^T K_hat S)^{-1} S^T, v_i = C_i y
15
// Sigma_i(x,x') = k(x,x') - k(x)^T C_i k(x')
16
//
17
// with K_hat = K + sigma^2 I. Because C_i <= K_hat^{-1} in the Loewner order,
18
// Sigma_i is an UPPER bound on the exact posterior covariance: the belief is
19
// never tighter than the computation justifies. That is the property this
20
// codebase wants, where an ill-conditioned kernel plus a truncated CG solve
21
// otherwise yields confident extrapolation.
22
//
23
// The split is additive and exact:
24
//
25
// Sigma_i = Sigma_exact + (k(x)^T (K_hat^{-1} - C_i) k(x'))
26
// \________/ \____________________________/
27
// mathematical computational
28
//
29
// so a caller can report which part of its uncertainty comes from having
30
// finite data and which from having stopped solving early.
31
32
#ifndef GPR_ML_GP_ITERGP_H_
33
#define GPR_ML_GP_ITERGP_H_
34
35
#include <Eigen/Cholesky>
36
#include <Eigen/Core>
37
38
namespace
gpr
{
39
namespace
itergp
{
40
44
enum class
Policy
{
45
ConjugateGradient
,
46
Unit
,
47
};
48
54
class
IterGP
{
55
public
:
59
void
run
(
const
Eigen::MatrixXd& K_hat,
const
Eigen::VectorXd&
y
,
60
int
iterations
,
Policy
policy
=
Policy::ConjugateGradient
);
61
62
[[nodiscard]]
int
iterations
() const noexcept
63
{
64
return
static_cast<
int
>
(S_.cols());
65
}
66
68
[[nodiscard]]
const
Eigen::MatrixXd&
actions
() const noexcept
69
{
70
return
S_;
71
}
72
74
[[nodiscard]]
const
Eigen::VectorXd&
representerWeights
() const noexcept
75
{
76
return
v_;
77
}
78
81
[[nodiscard]] Eigen::MatrixXd
inverseApproximation
()
const
;
82
84
[[nodiscard]]
double
posteriorMean
(
const
Eigen::VectorXd& kx)
const
;
85
88
[[nodiscard]]
double
combinedVariance
(
double
kxx,
89
const
Eigen::VectorXd& kx)
const
;
90
94
[[nodiscard]]
double
computationalVariance
(
95
const
Eigen::LDLT<Eigen::MatrixXd>& exact,
96
const
Eigen::VectorXd& kx)
const
;
97
99
[[nodiscard]]
double
relativeResidual
(
const
Eigen::MatrixXd& K_hat,
100
const
Eigen::VectorXd&
y
)
const
;
101
102
private
:
103
Eigen::MatrixXd S_;
104
Eigen::MatrixXd KS_;
105
Eigen::MatrixXd Sinv_;
106
Eigen::VectorXd v_;
107
};
108
109
}
// namespace itergp
110
}
// namespace gpr
111
112
#endif
// GPR_ML_GP_ITERGP_H_
y
@ y
Definition
Enums.h:28
gpr::itergp::IterGP
Definition
IterGP.h:54
gpr::itergp::IterGP::posteriorMean
double posteriorMean(const Eigen::VectorXd &kx) const
Posterior mean at a test point with cross-covariance k(x) = K_xn.
Definition
IterGP.cpp:102
gpr::itergp::IterGP::actions
const Eigen::MatrixXd & actions() const noexcept
The actions taken, n x i.
Definition
IterGP.h:68
gpr::itergp::IterGP::relativeResidual
double relativeResidual(const Eigen::MatrixXd &K_hat, const Eigen::VectorXd &y) const
Relative residual ||K_hat v_i - y|| / ||y||, the usual convergence view.
Definition
IterGP.cpp:135
gpr::itergp::IterGP::representerWeights
const Eigen::VectorXd & representerWeights() const noexcept
v_i = C_i y, the representer weights the run justifies.
Definition
IterGP.h:74
gpr::itergp::IterGP::inverseApproximation
Eigen::MatrixXd inverseApproximation() const
Definition
IterGP.cpp:94
gpr::itergp::IterGP::computationalVariance
double computationalVariance(const Eigen::LDLT< Eigen::MatrixXd > &exact, const Eigen::VectorXd &kx) const
Definition
IterGP.cpp:123
gpr::itergp::IterGP::iterations
int iterations() const noexcept
Definition
IterGP.h:62
gpr::itergp::IterGP::combinedVariance
double combinedVariance(double kxx, const Eigen::VectorXd &kx) const
Definition
IterGP.cpp:110
gpr::itergp::IterGP::run
void run(const Eigen::MatrixXd &K_hat, const Eigen::VectorXd &y, int iterations, Policy policy=Policy::ConjugateGradient)
Definition
IterGP.cpp:15
gpr::itergp
Definition
IterGP.cpp:13
gpr::itergp::Policy
Policy
Definition
IterGP.h:44
gpr::itergp::Policy::Unit
@ Unit
s_i = e_i, the i-th coordinate direction
Definition
IterGP.h:46
gpr::itergp::Policy::ConjugateGradient
@ ConjugateGradient
s_i = residual of the current iterate
Definition
IterGP.h:45
gpr::policy
Definition
TrainingPolicy.h:35
gpr
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition
Macros.h:16
gpr
ml
gp
IterGP.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf