Modular
Plug in new models, acquisition functions, and optimizers.
Built on PyTorch
Easily integrate neural network modules. Native GPU & autograd support.
Scalable
Support for scalable GPs via GPyTorch. Run code on multiple devices.
conda install botorch -c pytorch
pip install botorch
import torch
from botorch.models import SingleTaskGP
from botorch.fit import fit_gpytorch_model
from gpytorch.mlls import ExactMarginalLogLikelihood
train_X = torch.rand(10, 2)
Y = 1 - torch.norm(train_X - 0.5, dim=-1) + 0.1 * torch.rand(10)
train_Y = (Y - Y.mean()) / Y.std()
gp = SingleTaskGP(train_X, train_Y)
mll = ExactMarginalLogLikelihood(gp.likelihood, gp)
fit_gpytorch_model(mll)
from botorch.acquisition import UpperConfidenceBound
UCB = UpperConfidenceBound(gp, beta=0.1)
from botorch.optim import joint_optimize
bounds = torch.stack([torch.zeros(2), torch.ones(2)])
candidate = joint_optimize(
UCB, bounds=bounds, q=1, num_restarts=5, raw_samples=20,
)
candidate # tensor([0.4887, 0.5063])