pytspl.hogde_gp.exact_gp
Module for the ExactGPModel class.
Classes
The base class for any Gaussian process latent function to be used in conjunction |
Module Contents
- class pytspl.hogde_gp.exact_gp.ExactGPModel(train_x: torch.tensor, train_y: torch.tensor, likelihood: gpytorch.likelihoods, kernel: gpytorch.kernels.Kernel, mean_function=None)[source]
Bases:
gpytorch.models.ExactGPThe base class for any Gaussian process latent function to be used in conjunction with exact inference.
- Parameters:
train_inputs (torch.Tensor) – (size n x d) The training features \(\mathbf X\).
train_targets (torch.Tensor) – (size n) The training targets \(\mathbf y\).
likelihood (GaussianLikelihood) – The Gaussian likelihood that defines the observational distribution. Since we’re using exact inference, the likelihood must be Gaussian.
The
forward()function should describe how to compute the prior latent distribution on a given input. Typically, this will involve a mean and kernel function. The result must be aMultivariateNormal.Calling this model will return the posterior of the latent Gaussian process when conditioned on the training data. The output will be a
MultivariateNormal.- Example:
>>> class MyGP(gpytorch.models.ExactGP): >>> def __init__(self, train_x, train_y, likelihood): >>> super().__init__(train_x, train_y, likelihood) >>> self.mean_module = gpytorch.means.ZeroMean() >>> self.covar_module = gpytorch.kernels.ScaleKernel(gpytorch.kernels.RBFKernel()) >>> >>> def forward(self, x): >>> mean = self.mean_module(x) >>> covar = self.covar_module(x) >>> return gpytorch.distributions.MultivariateNormal(mean, covar) >>> >>> # train_x = ...; train_y = ... >>> likelihood = gpytorch.likelihoods.GaussianLikelihood() >>> model = MyGP(train_x, train_y, likelihood) >>> >>> # test_x = ...; >>> model(test_x) # Returns the GP latent function at test_x >>> likelihood(model(test_x)) # Returns the (approximate) predictive posterior distribution at test_x
- covar_module