GaPFlow.models.gp.GaussianProcessSurrogate#
- class GaPFlow.models.gp.GaussianProcessSurrogate(fc, database)#
Bases:
objectAbstract base class for Gaussian Process (GP) surrogate models.
Implements GP training, inference, and active learning routines. Subclasses must define abstract properties that describe the kernel hyperparameters, data arrays, and noise models.
- __init__(fc, database)#
Constructor.
- Parameters:
fc (muGrid.GlobalFieldCollection) – Field container with accessors for real fields such as ‘solution’ and ‘topography’.
database (GaPFlow.db.Database) – Training database providing initialize, add_data, and size attributes.
Methods
__init__(fc, database)Constructor.
build_gp(params, X, yerr)Default GP build method.
init_database(dim)Triggers the first database initialization.
predict([predictor, compute_var, cooldown])Perform GP prediction, optionally updating the model via active learning (only in predictor step of the predictor-corrector time integration scheme)
Log current GP hyperparameters and diagnostics.
Attributes
Test inputs.
Training inputs (normalized).
Training inputs (normalized).
Observations standard error.
Observations scaling factor.
Observations shift.
Training observations (only active dimensions, scaled).
Cumulative time spent for inference from the GP (making predictions)
Cumulative time spent for training of the GP (fitting hyperparameters)
The database holding the training data for the GP surrogate model.
Return constant extra field, which can be used as additional input.
Return the gap height field.
Return the topography (height and gradients).
Kernel lengthscale(s).
Kernel variance.
Size of the training database at the last fit.
Optimization objective (negative marginal log likelihood)
Observation noise standard deviation.
Return full solution field.
Return True if model predictive variance is below tolerance.
- abstract property Xtest#
Test inputs.
- property Xtrain: Array#
Training inputs (normalized).
- property Xtrain_target: Array#
Training inputs (normalized).
- abstract property Yerr#
Observations standard error.
- abstract property Yscale#
Observations scaling factor.
- abstract property Yshift#
Observations shift.
- abstract property Ytrain#
Training observations (only active dimensions, scaled).
- active_dims: list[int]#
- allowed_skips: int#
- atol: float#
- build_gp(params: dict, X: Array, yerr: float | Array) GaussianProcess#
Default GP build method.
- Parameters:
params (dict) – Dictionary with hyperparameters
X (jax.Array) – Input data.
yerr (jax.Array) – Observation noise (standard deviation).
- Returns:
Single-output GP model.
- Return type:
tinygp.GaussianProcess
- property cumtime_infer#
Cumulative time spent for inference from the GP (making predictions)
- property cumtime_train#
Cumulative time spent for training of the GP (fitting hyperparameters)
- property database#
The database holding the training data for the GP surrogate model.
- property extra#
Return constant extra field, which can be used as additional input.
- fix_noise: bool#
- geo: dict#
- property has_multi_output#
- property height#
Return the gap height field.
- property height_and_slopes: Array#
Return the topography (height and gradients).
- init_database(dim: int) None#
Triggers the first database initialization.
- Parameters:
dim (int) – Dimension of the fluid problem.
- is_gp_model: bool#
- abstract property kernel_lengthscale#
Kernel lengthscale(s).
- abstract property kernel_variance#
Kernel variance.
- property last_fit_train_size#
Size of the training database at the last fit.
- max_steps: int#
- name: str#
- noise: Tuple[float, float]#
- property objective#
Optimization objective (negative marginal log likelihood)
- abstract property obs_stddev#
Observation noise standard deviation.
- params_init: dict#
- pause_on_high_residual: bool#
- pause_steps: int#
- perturb_target: bool#
- predict(predictor: bool = True, compute_var: bool = True, cooldown: bool = False) Tuple[Array, Array]#
Perform GP prediction, optionally updating the model via active learning (only in predictor step of the predictor-corrector time integration scheme)
- Parameters:
predictor (bool, optional) – Whether to perform active learning updates (only in predictor step, default is True).
compute_var (bool, optional) – If true (default), preditive variance is re-computed.
cooldown (bool, optional) – If true, active learning is blocked to let the system cool down (default is False).
- Returns:
m (jax.Array) – Predictive mean.
v (jax.Array) – Predictive variance.
- prop: dict#
- rtol: float#
- save_state() None#
Log current GP hyperparameters and diagnostics.
- similarity_check: bool#
- property solution#
Return full solution field.
- tol: str#
- property trusted: bool#
Return True if model predictive variance is below tolerance.
- use_active_learning: bool#