GPyTorch models
GPSat models based on the GPyTorch python package.
Note
This is still under development.
- class GPSat.models.gpytorch_models.ExactGPR(train_x, train_y, kernel, likelihood, mean=None)
Bases:
ExactGP
- forward(x)
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class GPSat.models.gpytorch_models.GPyTorchGPRModel(data=None, coords_col=None, obs_col=None, coords=None, obs=None, coords_scale=None, obs_scale=None, obs_mean=None, *, kernel='MaternKernel', kernel_kwargs=None, mean_function: Mean = None, mean_func_kwargs: dict = None, noise_variance: float = None, likelihood: GaussianLikelihood = None, **kwargs)
Bases:
BaseGPRModel
- get_kernel_variance()
- get_lengthscales()
- get_likelihood_variance()
- get_objective_function_value()
Get value of objection function used to train the model. e.g. the log marginal likelihood when using exact GPR. Any inheriting class should override this method.
- get_smoothness()
Smoothness of Matern kernel (e.g. 0.5, 1.5, 2.5) specified explicitly in GPyTorch
- optimise_parameters(optimiser='adam', iterations=30)
Method to fit data on model by optimising (hyper/variational)-parameters. Any inheriting class should override this method.
- property param_names: list
Property method that returns the names of parameters in a list. Any inheriting class should override this method.
Each parameter name should have a
get_*
andset_*
method. e.g. ifparam_names = ['A', 'B']
then methodsget_A
,set_A
,get_B
,set_B
should be defined.Additionally, one can specify a
set_*_constraints
method that imposes constraints on the parameters during training, if applicable.
- predict(coords, full_cov=False, apply_scale=True)
method to generate prediction at given coords
- set_kernel_variance(kernel_variance)
- set_kernel_variance_constraints(low, high, move_within_tol=True, tol=1e-08, scale=False)
- set_lengthscales(lengthscales)
- set_lengthscales_constraints(low, high, move_within_tol=True, tol=1e-08, scale=False)
- set_likelihood_variance(likelihood_variance)
- set_likelihood_variance_constraints(low, high, move_within_tol=True, tol=1e-08, scale=False)
- set_smoothness(smoothness)
- class GPSat.models.gpytorch_models.GPyTorchKISSGPModel(data=None, coords_col=None, obs_col=None, coords=None, obs=None, coords_scale=None, obs_scale=None, obs_mean=None, *, kernel='MaternKernel', kernel_kwargs=None, mean_function: Mean = None, mean_func_kwargs: dict = None, noise_variance: float = None, likelihood: GaussianLikelihood = None, **kwargs)
Bases:
GPyTorchGPRModel
- get_lengthscales()
- get_smoothness()
Smoothness of Matern kernel (e.g. 0.5, 1.5, 2.5) specified explicitly in GPyTorch
- set_lengthscale_constraints(low, high, move_within_tol=True, tol=1e-08, scale=False)
- set_lengthscales(lengthscales)
- set_smoothness(smoothness)