gpytorchο
- Version:
1.5.1
- Category:
ai
- Cluster:
Loki
Descriptionο
GPyTorch is a Gaussian process (GP) library implemented in PyTorch, designed for creating scalable and flexible GP models using modern GPU hardware. It supports stochastic variational inference, exact GP regression, and multitask modeling using PyTorchβs autograd system.
Version 1.5.1 includes:
Improved support for gpytorch.mlls and variational inference
LazyTensor-based kernel operations
Runtime performance optimizations with GPU acceleration (CUDA 11.2)
Integration with PyTorch 1.9+
GPyTorch is particularly useful for applications in Bayesian optimization, time-series modeling, and scientific regression tasks.
Documentationο
>>> import gpytorch
>>> print(gpytorch.__version__)
'1.5.1'
Core APIs:
----------
gpytorch.models.ExactGP
gpytorch.likelihoods.GaussianLikelihood
gpytorch.kernels.ScaleKernel, RBFKernel, MaternKernel
gpytorch.distributions.MultivariateNormal
gpytorch.mlls.ExactMarginalLogLikelihood
CLI/Help:
>>> help(gpytorch)
>>> gpytorch.settings
Examples/Usageο
Load the module:
$ module load gpytorch-py37-cuda11.2-gcc8/1.5.1
Example: exact GP regression (simplified):
import torch
import gpytorch
train_x = torch.linspace(0, 1, 100)
train_y = torch.sin(train_x * (2 * torch.pi)) + torch.randn(train_x.size()) * 0.2
class ExactGPModel(gpytorch.models.ExactGP):
def __init__(self, train_x, train_y, likelihood):
super().__init__(train_x, train_y, likelihood)
self.mean_module = gpytorch.means.ConstantMean()
self.covar_module = gpytorch.kernels.ScaleKernel(gpytorch.kernels.RBFKernel())
def forward(self, x):
mean_x = self.mean_module(x)
covar_x = self.covar_module(x)
return gpytorch.distributions.MultivariateNormal(mean_x, covar_x)
likelihood = gpytorch.likelihoods.GaussianLikelihood()
model = ExactGPModel(train_x, train_y, likelihood)
Unload the module:
$ module unload gpytorch-py37-cuda11.2-gcc8/1.5.1
Installationο
Source code is obtained from GPyTorch