gpridge.surrogate¶
Layered-chain configuration for the GP surrogate.
Surrogate is an immutable fluent builder describing which arm of the
layered chain (MAP / +PSIS-Laplace / +INLA-Delta / +RFF) the underlying
GP uses. Compose it with .delta(), .rff(D), .psis() and
.with_hyperparameter_mode('inla'). Pass the result to
GaussianProcess as surrogate=.
Example:
Surrogate.map()
Surrogate.map().hssvd()
Surrogate.laplace_slice()
Surrogate.laplace_slice().delta()
Surrogate.laplace_slice().delta().rff(512)
Classes¶
Immutable, hashable layered-chain config. |
Module Contents¶
- class gpridge.surrogate.Surrogate¶
Immutable, hashable layered-chain config.
Build one with
map()orlaplace_slice()and refine it with the chain modifiers, each of which returns a new object. The fields below are the stored settings.- uncertainty_mode: str = 'map'¶
Posterior arm, one of
"map","bma","laplace","laplace-slice","eb"or"svgd". The factories set it.
- delta_uh_min_diag: float = 1e-06¶
Conditioning gate of the delta correction. The correction is switched off when
min(diag(U_H))falls below this value. Zero or negative disables the gate. The default matches the C++ side.
- delta_max_ratio: float = 100.0¶
Cap of the per-query delta variance as a multiple of the signal variance. Zero or negative disables the cap. The default matches the C++ side.
- rff_features: int = 0¶
Number of random Fourier features. 0 keeps the exact kernel and -1 selects the count against held-out data (
"auto").
- rff_force_tol_fraction: float = 0.0¶
Share of the force tolerance that the automatic selection may spend. 0 derives the share from the gradient noise. Used only when
rff_featuresis -1.
- hyperparameter_mode: str = 'scg'¶
Hyperparameter optimiser,
"scg"(scaled conjugate gradient) or"inla".
- classmethod laplace_slice(*, deterministic: bool = True) Surrogate¶
Laplace-slice posterior with PSIS smoothing enabled.
deterministicselects the deterministic PSIS grid.
- delta(*, uh_min_diag: float | None = None, max_ratio: float | None = None) Surrogate¶
Enable the alpha-K Hessian Laplace variance correction.
uh_min_diagandmax_ratioset the conditioning gate and per-query magnitude cap on the correction; defaults match the C++ defaults (1e-6, 100.0). Pass <= 0 to disable each guard. The defaults are usually sufficient; tighten them (e.g. uh_min_diag=1e-4) on small-N NEB chains where the Hessian is very poorly conditioned.
- psis(*, deterministic: bool = True) Surrogate¶
Enable PSIS on the Laplace slice; needs a
laplace_slicebase.Raises
ValueErroron any other base.
- rff(n_features: int | str, force_tol_fraction: float = 0.0) Surrogate¶
Fix the feature count, or pass
"auto"to select it."auto"(stored as -1) doubles the count until the held-out random-feature posterior matches the exact GP. A positive count still requires a Laplace-slice surrogate.force_tol_fractionis the share of the 0.0514221 eV/Å force tolerance the automatic rule may spend; 0 derives that share from the gradient noise.Raises
ValueErrorfor a negative count, a string other than"auto", a positive count on a base other thanlaplace_slice, or a fraction outside [0, 1).