pytorch / botorch
- пятница, 3 мая 2019 г. в 00:18:49
Python
Bayesian optimization in PyTorch
BoTorch is a library for Bayesian Optimization built on PyTorch.
BoTorch is currently in beta and under active development!
BoTorch
The primary audience for hands-on use of BoTorch are researchers and sophisticated practitioners in Bayesian Optimization and AI. We recommend using BoTorch as a low-level API for implementing new algorithms for Ax. Ax has been designed to be an easy-to-use platform for end-users, which at the same time is flexible enough for Bayesian Optimization researchers to plug into for handling of feature transformations, (meta-)data management, storage, etc. We recommend that end-users who are not actively doing research on Bayesian Optimization simply use Ax.
Installation Requirements
The latest release of BoTorch is easily installed either via Anaconda (recommended):
conda install botorch -c pytorchor via pip:
pip install botorchImportant note for MacOS users:
If you'd like to try our bleeding edge features (and don't mind potentially running into the occasional bug here or there), you can install the latest master directly from GitHub (this will also require installing the current GPyTorch master):
pip install git+https://github.com/cornellius-gp/gpytorch.git
pip install git+https://github.com/pytorch/botorch.gitManual / Dev install
Alternatively, you can do a manual install. For a basic install, run:
git clone https://github.com/pytorch/botorch.git
cd botorch
pip install -e .To customize the installation, you can also run the following variants of the above:
pip install -e .[dev]: Also installs all tools necessary for development
(testing, linting, docs building; see Contributing below).pip install -e .[tutorials]: Also installs all packages necessary for running the tutorial notebooks.Here's a quick run down of the main components of a Bayesian optimization loop. For more details see our Documentation and the Tutorials.
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,
)See the CONTRIBUTING file for how to help out.
BoTorch is MIT licensed, as found in the LICENSE file.