Bayesian optimization in PyTorch

Overview
BoTorch Logo

Lint Test Docs Tutorials Codecov

Conda PyPI License

BoTorch is a library for Bayesian Optimization built on PyTorch.

BoTorch is currently in beta and under active development!

Why BoTorch ?

BoTorch

  • Provides a modular and easily extensible interface for composing Bayesian optimization primitives, including probabilistic models, acquisition functions, and optimizers.
  • Harnesses the power of PyTorch, including auto-differentiation, native support for highly parallelized modern hardware (e.g. GPUs) using device-agnostic code, and a dynamic computation graph.
  • Supports Monte Carlo-based acquisition functions via the reparameterization trick, which makes it straightforward to implement new ideas without having to impose restrictive assumptions about the underlying model.
  • Enables seamless integration with deep and/or convolutional architectures in PyTorch.
  • Has first-class support for state-of-the art probabilistic models in GPyTorch, including support for multi-task Gaussian Processes (GPs) deep kernel learning, deep GPs, and approximate inference.

Target Audience

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

Installation Requirements

  • Python >= 3.7
  • PyTorch >= 1.7.1
  • gpytorch >= 1.4
  • scipy
Installing the latest release

The latest release of BoTorch is easily installed either via Anaconda (recommended):

conda install botorch -c pytorch -c gpytorch

or via pip:

pip install botorch

You can customize your PyTorch installation (i.e. CUDA version, CPU only option) by following the PyTorch installation instructions.

Important note for MacOS users:

  • Make sure your PyTorch build is linked against MKL (the non-optimized version of BoTorch can be up to an order of magnitude slower in some settings). Setting this up manually on MacOS can be tricky - to ensure this works properly, please follow the PyTorch installation instructions.
  • If you need CUDA on MacOS, you will need to build PyTorch from source. Please consult the PyTorch installation instructions above.
Installing from latest master

If you would 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 --upgrade git+https://github.com/cornellius-gp/gpytorch.git
pip install --upgrade git+https://github.com/pytorch/botorch.git

Manual / 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.

Getting Started

Here's a quick run down of the main components of a Bayesian optimization loop. For more details see our Documentation and the Tutorials.

  1. Fit a Gaussian Process model to data
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 - (train_X - 0.5).norm(dim=-1, keepdim=True)  # explicit output dimension
Y += 0.1 * torch.rand_like(Y)
train_Y = (Y - Y.mean()) / Y.std()

gp = SingleTaskGP(train_X, train_Y)
mll = ExactMarginalLogLikelihood(gp.likelihood, gp)
fit_gpytorch_model(mll)
  1. Construct an acquisition function
from botorch.acquisition import UpperConfidenceBound

UCB = UpperConfidenceBound(gp, beta=0.1)
  1. Optimize the acquisition function
from botorch.optim import optimize_acqf

bounds = torch.stack([torch.zeros(2), torch.ones(2)])
candidate, acq_value = optimize_acqf(
    UCB, bounds=bounds, q=1, num_restarts=5, raw_samples=20,
)

Citing BoTorch

If you use BoTorch, please cite the following paper:

M. Balandat, B. Karrer, D. R. Jiang, S. Daulton, B. Letham, A. G. Wilson, and E. Bakshy. BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization. Advances in Neural Information Processing Systems 33, 2020.

@inproceedings{balandat2020botorch,
  title={{BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization}},
  author={Balandat, Maximilian and Karrer, Brian and Jiang, Daniel R. and Daulton, Samuel and Letham, Benjamin and Wilson, Andrew Gordon and Bakshy, Eytan},
  booktitle = {Advances in Neural Information Processing Systems 33},
  year={2020},
  url = {http://arxiv.org/abs/1910.06403}
}

See here for an incomplete selection of peer-reviewed papers that build off of BoTorch.

Contributing

See the CONTRIBUTING file for how to help out.

License

BoTorch is MIT licensed, as found in the LICENSE file.

Issues
  • Numerical issue with cholesky decomposition (even with normalization)

    Numerical issue with cholesky decomposition (even with normalization)

    Issue description

    I am consistently running into numerical issues when running fit_gpytorch_model(). I am normalizing the inputs and standardizing the outputs (as described in issue 160)

    Code example

    fit_gpytorch_model(mll)
    EI = ExpectedImprovement(gp, best_f=0.1)
    
    ## optimize acquisition function
    candidates = joint_optimize(
        acq_function=EI,
        q = 1, 
        bounds = bounds,
        num_restarts=10,
        raw_samples=500,  # used for intialization heuristic
    )
    
    new_x = candidates.detach()
    exact_obj = neg_eggholder(new_x)
    
    train_x_ei = torch.cat([train_x_ei, candidates])
    train_y_ei = torch.cat([train_y_ei, exact_obj])
    
    gp = SingleTaskGP(
        normalize(train_x_ei, bounds=bounds), 
        standardize(train_y_ei)
        )
    mll = ExactMarginalLogLikelihood(gp.likelihood, gp)
    

    Here is the error message:

    RuntimeError Traceback (most recent call last) in 2 3 ----> 4 fit_gpytorch_model(mll) 5 EI = ExpectedImprovement(gp, best_f=0.1) 6

    C:\Anaconda3\envs\py36_new\lib\site-packages\botorch\fit.py in fit_gpytorch_model(mll, optimizer, **kwargs) 33 """ 34 mll.train() ---> 35 mll, _ = optimizer(mll, track_iterations=False, **kwargs) 36 mll.eval() 37 return mll

    C:\Anaconda3\envs\py36_new\lib\site-packages\botorch\optim\fit.py in fit_gpytorch_scipy(mll, bounds, method, options, track_iterations) 186 jac=True, 187 options=options, --> 188 callback=cb, 189 ) 190 iterations = []

    C:\Anaconda3\envs\py36_new\lib\site-packages\scipy\optimize_minimize.py in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options) 599 elif meth == 'l-bfgs-b': 600 return _minimize_lbfgsb(fun, x0, args, jac, bounds, --> 601 callback=callback, **options) 602 elif meth == 'tnc': 603 return _minimize_tnc(fun, x0, args, jac, bounds, callback=callback,

    C:\Anaconda3\envs\py36_new\lib\site-packages\scipy\optimize\lbfgsb.py in _minimize_lbfgsb(fun, x0, args, jac, bounds, disp, maxcor, ftol, gtol, eps, maxfun, maxiter, iprint, callback, maxls, **unknown_options) 333 # until the completion of the current minimization iteration. 334 # Overwrite f and g: --> 335 f, g = func_and_grad(x) 336 elif task_str.startswith(b'NEW_X'): 337 # new iteration

    C:\Anaconda3\envs\py36_new\lib\site-packages\scipy\optimize\lbfgsb.py in func_and_grad(x) 283 else: 284 def func_and_grad(x): --> 285 f = fun(x, *args) 286 g = jac(x, *args) 287 return f, g

    C:\Anaconda3\envs\py36_new\lib\site-packages\scipy\optimize\optimize.py in function_wrapper(*wrapper_args) 298 def function_wrapper(wrapper_args): 299 ncalls[0] += 1 --> 300 return function((wrapper_args + args)) 301 302 return ncalls, function_wrapper

    C:\Anaconda3\envs\py36_new\lib\site-packages\scipy\optimize\optimize.py in call(self, x, *args) 61 def call(self, x, *args): 62 self.x = numpy.asarray(x).copy() ---> 63 fg = self.fun(x, *args) 64 self.jac = fg[1] 65 return fg[0]

    C:\Anaconda3\envs\py36_new\lib\site-packages\botorch\optim\fit.py in _scipy_objective_and_grad(x, mll, property_dict) 221 output = mll.model(*train_inputs) 222 args = [output, train_targets] + _get_extra_mll_args(mll) --> 223 loss = -mll(*args).sum() 224 loss.backward() 225 param_dict = OrderedDict(mll.named_parameters())

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\module.py in call(self, *inputs, **kwargs) 20 21 def call(self, *inputs, **kwargs): ---> 22 outputs = self.forward(*inputs, **kwargs) 23 if isinstance(outputs, list): 24 return [_validate_module_outputs(output) for output in outputs]

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\mlls\exact_marginal_log_likelihood.py in forward(self, output, target, *params) 26 # Get the log prob of the marginal distribution 27 output = self.likelihood(output, *params) ---> 28 res = output.log_prob(target) 29 30 # Add terms for SGPR / when inducing points are learned

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\distributions\multivariate_normal.py in log_prob(self, value) 127 128 # Get log determininat and first part of quadratic form --> 129 inv_quad, logdet = covar.inv_quad_logdet(inv_quad_rhs=diff.unsqueeze(-1), logdet=True) 130 131 res = -0.5 * sum([inv_quad, logdet, diff.size(-1) * math.log(2 * math.pi)])

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\lazy\lazy_tensor.py in inv_quad_logdet(self, inv_quad_rhs, logdet, reduce_inv_quad) 990 from .chol_lazy_tensor import CholLazyTensor 991 --> 992 cholesky = CholLazyTensor(self.cholesky()) 993 return cholesky.inv_quad_logdet(inv_quad_rhs=inv_quad_rhs, logdet=logdet, reduce_inv_quad=reduce_inv_quad) 994

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\lazy\lazy_tensor.py in cholesky(self, upper) 716 (LazyTensor) Cholesky factor (lower triangular) 717 """ --> 718 res = self._cholesky() 719 if upper: 720 res = res.transpose(-1, -2)

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\utils\memoize.py in g(self, *args, **kwargs) 32 cache_name = name if name is not None else method 33 if not is_in_cache(self, cache_name): ---> 34 add_to_cache(self, cache_name, method(self, *args, **kwargs)) 35 return get_from_cache(self, cache_name) 36

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\lazy\lazy_tensor.py in _cholesky(self) 401 evaluated_mat.register_hook(_ensure_symmetric_grad) 402 --> 403 cholesky = psd_safe_cholesky(evaluated_mat.double()).to(self.dtype) 404 return NonLazyTensor(cholesky) 405

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\utils\cholesky.py in psd_safe_cholesky(A, upper, out, jitter) 45 continue 46 ---> 47 raise e 48 49

    C:\Anaconda3\envs\py36_new\lib\site-packages\gpytorch\utils\cholesky.py in psd_safe_cholesky(A, upper, out, jitter) 19 """ 20 try: ---> 21 L = torch.cholesky(A, upper=upper, out=out) 22 # TODO: Remove once fixed in pytorch (#16780) 23 if A.dim() > 2 and A.is_cuda:

    RuntimeError: cholesky_cpu: U(2,2) is zero, singular U.

    System Info

    BoTorch 0.1.0 GPyTorch 0.3.2 Torch 1.1.0 Windows 10

    opened by michaelyli 36
  • Adding proximal acquisition function wrapper

    Adding proximal acquisition function wrapper

    Motivation

    The goal of this acquisition function is to bias a GP optimization towards smooth optimization through the input domain. The proximal AF multiplies the base acquisition function by a squared exponential with a user defined lengthscale, centered at the most recently observed training point (assumed to be model.train_inputs[-1]). If the associated lengthscale is short the algorithm makes small jumps in input space, if it is long it is not strongly biased. This method differs from simply restricting the max travel size in input space by allowing large travel distances if the predicted value is large enough. See https://journals.aps.org/prab/abstract/10.1103/PhysRevAccelBeams.24.062801 for discussion and analysis.

    This becomes relevant when using Bayesian optimization techniques on optimizing physical systems, where there is a cost associated with changing input parameters.

    Have you read the Contributing Guidelines on pull requests?

    Yes, I've tried my best to satisfy all requirements although there are possibly errors (first time contributing to a major project like this).

    Test Plan

    Test script test_proximal.py has been added to test/acquisition. I can also provide numerical proof that this works with a simple script but I was unsure where to include. Result is show below figure_1

    Please comment if I need to change anything, thanks!

    Related PRs

    None

    CLA Signed Merged 
    opened by roussel-ryan 23
  • Support specifying observation noise explicitly

    Support specifying observation noise explicitly

    This adds support for specifying the observation noise in posterior and fantasize.

    In addition to using the observation noise from the likelihood by setting observation_noise=True, now observation_noise can be a tensor. In that case, the provided noise levels are used directly as the observation noise in the posterior predictive (not in performing inference).

    The primary use case for this is if we have auxiliary noise models that should not be used as the likelihood during posterior computations (e.g. b/c the model is fitted to already smoothed data), or because we have some dependency of the observation noise on parameters that we may control, e.g. the fidelity of the evaluation/sample size.

    Note: This depends on https://github.com/cornellius-gp/gpytorch/pull/865

    Also, this cleans up some of the boilerplate code in the gpytorch wrappers by defining the gpt_posterior_settings contextmanager that wraps the settings we use for posterior computation.

    CLA Signed Merged 
    opened by Balandat 19
  • low-rank cholesky updates for NEI

    low-rank cholesky updates for NEI

    Summary: This uses low-rank cholesky updates in NEI. Using SAA this allows us to cache the objectives values for the in-sample points and only compute the objectives for the new test points. This is much faster when there are lots of baseline points.

    However, this makes the acquisition function harder to read, so I am curious to hear what folks think.

    Moreover, this is a prototype that I am using for research, but many common components with NEHVI should be refactored into a shared utility or base class.

    Differential Revision: D32668278

    CLA Signed fb-exported 
    opened by sdaulton 17
  • Error when using FixedFeatureAcquisitionFunction and project with qMultifidelityKnowledgeGradient

    Error when using FixedFeatureAcquisitionFunction and project with qMultifidelityKnowledgeGradient

    Related tp #625 but opening a new issue since that one was closed.

    versions torch/gpytorch/botorch 1.7.0-cpu/1.3.0/0.3.3

    Reproducible example

    import math
    import torch
    
    import botorch
    botorch.__version__
    from botorch.fit import fit_gpytorch_model
    from botorch.models import SingleTaskGP
    from botorch.utils import standardize
    from gpytorch.mlls import ExactMarginalLogLikelihood
    
    d = 3
    bounds  = torch.stack([torch.zeros(d), torch.ones(d)])
    
    train_X = bounds[0] + (bounds[1] - bounds[0]) * torch.rand(15, d)
    train_Y = torch.sin(2 * math.pi * train_X[:, [0]]) 
    # train_Y = standardize(train_Y + 0.0 * torch.randn_like(train_Y))
    
    model   = SingleTaskGP(train_X, train_Y)
    mll     = ExactMarginalLogLikelihood(model.likelihood, model)
    fit_gpytorch_model(mll);
    
    def project(x):
        return torch.cat([x[..., :-1], torch.full_like(x[..., -1:], .5)], dim=-1)
    
    from botorch.acquisition import qKnowledgeGradient, qMultiFidelityKnowledgeGradient
    torch.manual_seed(123)
    num_fantasies = 64
    qKG           = qMultiFidelityKnowledgeGradient(model, num_fantasies=num_fantasies, project=project)
    
    from botorch.optim import optimize_acqf
    from botorch.utils.sampling import manual_seed
    
    with manual_seed(1234):
        candidates, acq_value = optimize_acqf(
            acq_function=qKG, 
            bounds=bounds,
            q=1,
            num_restarts=5,
            raw_samples=25,
            fixed_features={d-1:1.}
        )
    
    from botorch.acquisition import FixedFeatureAcquisitionFunction
    columns = [2]
    values  = [2.]
    qKG_FF = FixedFeatureAcquisitionFunction(qKG, 3, columns, values)
    
    from botorch.optim import optimize_acqf
    from botorch.utils.sampling import manual_seed
    
    ff_bounds = bounds[...,:-1].reshape(2,-1)
    with manual_seed(1234):
        candidates, acq_value = optimize_acqf(
            acq_function=qKG_FF, 
            bounds=ff_bounds,
            q=1,
            num_restarts=5,
            raw_samples=25,
        )
    
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    <ipython-input-30-2031d22c553b> in <module>
          9         q=1,
         10         num_restarts=5,
    ---> 11         raw_samples=25,
         12 #         fixed_features={d-1:1.}
         13     )
    
    ~\Anaconda3\lib\site-packages\botorch\optim\optimize.py in optimize_acqf(acq_function, bounds, q, num_restarts, raw_samples, options, inequality_constraints, equality_constraints, fixed_features, post_processing_func, batch_initial_conditions, return_best_only, sequential, **kwargs)
        155             num_restarts=num_restarts,
        156             raw_samples=raw_samples,
    --> 157             options=options,
        158         )
        159 
    
    ~\Anaconda3\lib\site-packages\botorch\optim\initializers.py in gen_batch_initial_conditions(acq_function, bounds, q, num_restarts, raw_samples, options)
        111                     end_idx = min(start_idx + batch_limit, X_rnd.shape[0])
        112                     Y_rnd_curr = acq_function(
    --> 113                         X_rnd[start_idx:end_idx].to(device=device)
        114                     ).cpu()
        115                     Y_rnd_list.append(Y_rnd_curr)
    
    ~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
        725             result = self._slow_forward(*input, **kwargs)
        726         else:
    --> 727             result = self.forward(*input, **kwargs)
        728         for hook in itertools.chain(
        729                 _global_forward_hooks.values(),
    
    ~\Anaconda3\lib\site-packages\botorch\acquisition\fixed_feature.py in forward(self, X)
         82         """
         83         X_full = self._construct_X_full(X)
    ---> 84         return self.acq_func(X_full)
         85 
         86     def _construct_X_full(self, X: Tensor) -> Tensor:
    
    ~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
        725             result = self._slow_forward(*input, **kwargs)
        726         else:
    --> 727             result = self.forward(*input, **kwargs)
        728         for hook in itertools.chain(
        729                 _global_forward_hooks.values(),
    
    ~\Anaconda3\lib\site-packages\botorch\utils\transforms.py in decorated(cls, X, **kwargs)
        167                 )
        168             X = X if X.dim() > 2 else X.unsqueeze(0)
    --> 169             return method(cls, X, **kwargs)
        170 
        171         return decorated
    
    ~\Anaconda3\lib\site-packages\botorch\acquisition\knowledge_gradient.py in forward(self, X)
        402                 maximized at fixed `X_actual[b]`.
        403         """
    --> 404         X_actual, X_fantasies = _split_fantasy_points(X=X, n_f=self.num_fantasies)
        405 
        406         # We only concatenate X_pending into the X part after splitting
    
    ~\Anaconda3\lib\site-packages\botorch\acquisition\knowledge_gradient.py in _split_fantasy_points(X, n_f)
        503     if n_f > X.size(-2):
        504         raise ValueError(
    --> 505             f"n_f ({n_f}) must be less than the q-batch dimension of X ({X.size(-2)})"
        506         )
        507     split_sizes = [X.size(-2) - n_f, n_f]
    
    ValueError: n_f (64) must be less than the q-batch dimension of X (1)
    
    opened by r-ashwin 17
  • [question] Can qNEHVI be used with KroneckerMultiTaskGP?

    [question] Can qNEHVI be used with KroneckerMultiTaskGP?

    Following this tutorial, I was trying to swap the ModelListGP model for a KroneckerMultiTaskGP, with this modification (leaving everything else the same):

    def initialize_model(train_x, train_obj):
        model = KroneckerMultiTaskGP(train_x, train_obj, outcome_transform=Standardize(m=train_obj.shape[-1]))
        mll = ExactMarginalLogLikelihood(model.likelihood, model)
        return mll, model
    

    With this model, the BO loop fails at optimize_qnehvi_and_get_observation() with error:

    AttributeError: 'TransformedPosterior' object has no attribute 'mvn'
    

    Does that mean that KroneckerMultiTaskGP cannot be used with qNEHVI as it doesn't have the MultitaskMultivariateNormal attribute or am I misinterpreting this? Are any other changes necessary?

    Thanks a lot!

    opened by alinaselega 16
  • [botorch] Sampling Strategies

    [botorch] Sampling Strategies

    This adds support for SamplingStrategy, an abstract alternative point generation method that samples from some discrete set of candidate points. In that, it is fundamentally different from acquisition functions, which compute acquisition values for a set of points and then rely on some external optimization over these points to generate candidates.

    The prime example for this is discrete Thompson Sampling, which samples points from a (typically large) input set X according to the probability that a point has the highest objective under the model posterior.

    For an input X of shape batch_shape x N x d this by default draws a single (joint) sample and returns the X associated with the maximum value (as shape batch_shape x d).

    It's also possible to pass in a n argument that results in returning n samples of the above kind, returning them as n x batch_shape x d

    Another strategy is TemperedAcqiusitionSampling, which, given an analytic acquisition funtion acq_func, draws samples from X according to a multinomial distribution over its indices given by weight(X) ~ exp(eta * standardize(acq_func(X))), where standardize(Y) standardizes Y to zero mean and unit variance. As the temperature parameter eta -> 0, this approaches uniform sampling, while as eta -> infty, this approaches selecting the maximizer(s) of the acquisition function acq_func.

    Since SamplingStrategy doesn't fit the semantics of the existing acquisition functions, this adds a new module botorch.generation.sampling for sampling-based generation strategies. The existing gen module is moved as a submodule into this module, and imports from botorch.gen are being deprecated.

    enhancement CLA Signed Merged 
    opened by Balandat 16
  • Add X as optional arg to call signature of MCAcqusitionObjective

    Add X as optional arg to call signature of MCAcqusitionObjective

    Summary: This was requested in https://github.com/pytorch/botorch/issues/663.

    Differential Revision: D25938012

    CLA Signed Merged fb-exported 
    opened by Balandat 16
  • require PyTorch 1.2

    require PyTorch 1.2

    Summary: require pytorch 1.2 to incorporate changes regarding bool tensors

    Reviewed By: Balandat

    Differential Revision: D16725568

    CLA Signed Merged 
    opened by sdaulton 16
  • Consolidate and simplify multi-fidelity models

    Consolidate and simplify multi-fidelity models

    Summary: This diff does some cleanup of multi-fidelity models in BoTorch to facilitate future integration of multi-fidelity optimization through Ax.

    More specifically, it does the following:

    1. Remove the fidelity submodule, now there is only a kernel submodule (which currently only contains MF Kernels). gp_regression_fidelity.py was moved into botorch.models.
    2. Change the interface of LinearTruncatedFidelityKernel to take a fidelity_dims list of indices for fidelity dimensions. This improves compatibility with the specification in the CostAwareUtility setup. Further, streamline the implementation without changing the rest of the functionality
    3. Remove SingleTaskGPLTKernel in favor of a linear_truncated kwarg in SingleTaskMultiFidelityGP

    Differential Revision: D18239523

    CLA Signed Merged 
    opened by Balandat 16
  • add abstract box decomposition and refactor box decomposition file structure

    add abstract box decomposition and refactor box decomposition file structure

    Summary: see title. This will tidy things up for future additions.

    This also requires that a reference point is specified upon initialization.

    Differential Revision: D25725167

    CLA Signed Merged fb-exported 
    opened by sdaulton 15
  • Add subset_output functionality to (some) models

    Add subset_output functionality to (some) models

    Summary: In some cases we want to be able to subset models along the output dimension. For instance, if we fit a multi-output model with a number of metrics, we may want to optimize an acquisition function with an objective that only involves a subset of the outputs. By subsetting the model prior to that, we can save a lot of compute.

    This diff adds a subset_output function to the model API. Calling this on a model with a list of indices will return a new model object that is restricted to the desired outputs.

    For some models (e.g AffineDeterministicModel or ModelListGP) the implementation is trivial. For others it's a little more involved but doable.The main challenge is with things like passing in generic covariance modules - we really don't have any way of knowing what dimensions of the respective buffers and parameters we need to subset / rescale in this case.

    Differential Revision: D18668985

    CLA Signed Merged fb-exported 
    opened by Balandat 15
  • Gibbon

    Gibbon

    Hi

    I have provided the GIBBON acquisition function (https://arxiv.org/abs/2102.03324).

    GIBBON is a very lightweight version of your MF-MES that uses a Determinantal Point Process-based formulation to allow it to have a fully analytical expression (i.e. does not require any fantasy simulations or numerical integration).

    I have included some basic unit tests. It seems like something funny is going on with your tests at the moment (i.e lots of them seem to fail in my build)?

    At the moment, I have included GIBBON within your MES file. Is this okay, or would you prefer it as part of the analytical acquisition function file?

    Would you also like me to write a notebook? GIBBON could be included in your MES notebook or as a stand-alone notebook. Which would you prefer and how much detail would you want in this?

    Thanks

    Henry

    enhancement CLA Signed Merged 
    opened by henrymoss 15
  • [Bug] HigherOrderGP batch evaluation fails on latest gpytorch master

    [Bug] HigherOrderGP batch evaluation fails on latest gpytorch master

    ๐Ÿ› Bug

    Batch posterior evaluation fails on https://github.com/cornellius-gp/gpytorch/pull/1813.

    The original failure seems is caused by another bug in gpytorch (addressed by https://github.com/cornellius-gp/gpytorch/pull/1819), but things still fail after fixing that.

    To reproduce

    (run on https://github.com/cornellius-gp/gpytorch/pull/1819)

    ** Code snippet to reproduce **

    import torch
    from botorch.models import HigherOrderGP
    
    train_x = torch.rand(10, 1)
    train_y = torch.randn(10, 3, 5)
    m = HigherOrderGP(train_x, train_y)
    
    test_x = torch.rand(2, 5, 1)
    
    m.posterior(test_x[0])  # works before and after gpytorch #1813
    
    m.posterior(test_x)  # fails on gpytorch #1813, worked prior
    

    ** Stack trace/error message **

    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    ~/Code/gpytorch/gpytorch/lazy/lazy_evaluated_kernel_tensor.py in _getitem(self, row_index, col_index, *batch_indices)
        111         try:
    --> 112             x2 = x2[(*batch_indices, col_index, dim_index)]
        113         # We're going to handle multi-batch indexing with a try-catch loop
    
    IndexError: too many indices for tensor of dimension 2
    
    During handling of the above exception, another exception occurred:
    
    RuntimeError                              Traceback (most recent call last)
    /var/folders/ly/jk17b129633cm92r5dhj4phr0000gn/T/ipykernel_8271/958233856.py in <module>
         10 m.posterior(test_x[0])
         11 
    ---> 12 m.posterior(test_x)
    
    ~/Code/botorch/botorch/models/higher_order_gp.py in posterior(self, X, output_indices, observation_noise, **kwargs)
        476                 pred_variance = mvn.variance
        477             else:
    --> 478                 pred_variance = self.make_posterior_variances(joint_covar)
        479 
        480             # mean and variance get reshaped into the target shape
    
    ~/Code/botorch/botorch/models/higher_order_gp.py in make_posterior_variances(self, joint_covariance_matrix)
        549         test_train_pred_covar = test_train_hadamard.matmul(train_inv_evals).sum(dim=-1)
        550 
    --> 551         pred_variances = full_test_test_covar.diag() - test_train_pred_covar
        552         return pred_variances
    
    ~/Code/gpytorch/gpytorch/lazy/kronecker_product_lazy_tensor.py in diag(self)
        137             if not self.is_square:
        138                 raise RuntimeError("Diag works on square matrices (or batches)")
    --> 139         return _kron_diag(*self.lazy_tensors)
        140 
        141     def diagonalization(self, method: Optional[str] = None):
    
    ~/Code/gpytorch/gpytorch/lazy/kronecker_product_lazy_tensor.py in _kron_diag(*lts)
         22     if len(lts) == 1:  # base case:
         23         return lead_diag
    ---> 24     trail_diag = _kron_diag(*lts[1:])
         25     diag = lead_diag.unsqueeze(-2) * trail_diag.unsqueeze(-1)
         26     return diag.transpose(-1, -2).reshape(*diag.shape[:-2], -1)
    
    ~/Code/gpytorch/gpytorch/lazy/kronecker_product_lazy_tensor.py in _kron_diag(*lts)
         19 def _kron_diag(*lts) -> Tensor:
         20     """Compute diagonal of a KroneckerProductLazyTensor from the diagonals of the constituiting tensors"""
    ---> 21     lead_diag = lts[0].diag()
         22     if len(lts) == 1:  # base case:
         23         return lead_diag
    
    ~/Code/gpytorch/gpytorch/lazy/lazy_tensor.py in diag(self)
       1065 
       1066         row_col_iter = torch.arange(0, self.matrix_shape[-1], dtype=torch.long, device=self.device)
    -> 1067         return self[..., row_col_iter, row_col_iter]
       1068 
       1069     def dim(self):
    
    ~/Code/gpytorch/gpytorch/lazy/lazy_tensor.py in __getitem__(self, index)
       2143                 self, (*batch_indices, row_index, col_index)
       2144             )
    -> 2145             res = self._get_indices(row_index, col_index, *batch_indices)
       2146         else:
       2147             res = self._getitem(row_index, col_index, *batch_indices)
    
    ~/Code/gpytorch/gpytorch/lazy/batch_repeat_lazy_tensor.py in _get_indices(self, row_index, col_index, *batch_indices)
         81 
         82         # Now call the sub _get_indices method
    ---> 83         res = self.base_lazy_tensor._get_indices(row_index, col_index, *batch_indices)
         84         return res
         85 
    
    ~/Code/gpytorch/gpytorch/lazy/lazy_tensor.py in _get_indices(self, row_index, col_index, *batch_indices)
        305         batch_indices = tuple(index.expand(final_shape) for index in batch_indices)
        306 
    --> 307         base_lazy_tensor = self._getitem(_noop_index, _noop_index, *batch_indices)._expand_batch(final_shape)
        308 
        309         # Create some interoplation indices and values
    
    ~/Code/gpytorch/gpytorch/lazy/lazy_evaluated_kernel_tensor.py in _getitem(self, row_index, col_index, *batch_indices)
        115         except IndexError:
        116             if any(not isinstance(bi, slice) for bi in batch_indices):
    --> 117                 raise RuntimeError(
        118                     "Attempting to tensor index a non-batch matrix's batch dimensions. "
        119                     f"Got batch index {batch_indices} but my shape was {self.shape}"
    
    RuntimeError: Attempting to tensor index a non-batch matrix's batch dimensions. Got batch index (tensor([[0, 0, 0],
            [0, 0, 0]]),) but my shape was torch.Size([1, 3, 3])
    
    
    bug 
    opened by Balandat 14
  • [question] How to do predictions using the trained GP models?

    [question] How to do predictions using the trained GP models?

    Issue description

    Hello! I recently start using BoTorch in my work on chemistry but i'm only newbie to bayes optimization and also programming. I was wondering how to use the GPmodels trained on my datasets to make predictions. Having tried my best to read the code but still cannot find a way. Hope to get your instructions and suggestions.

    Thank you so much for this great toolbox.

    Code example

    I'm just using the same code framework as the 'q-Noisy Constrained EI' in tutorial.

    System Info

    Please provide information about your setup, including

    • BoTorch Version 0.6.0
    • GPyTorch Version 1.6.0
    • Ubuntu
    opened by gooster1997 2
  • Adding constraints to Multi-fidelity BO with discrete fidielities

    Adding constraints to Multi-fidelity BO with discrete fidielities

    Issue description

    I was following the page of Multi-fidelity BO with discrete fidelities: https://botorch.org/tutorials/discrete_multi_fidelity_bo, and try to add inequality parameter constraints to the optimizer. I only modified the optimize_acqf_mixed() and optimize_acqf() functions as below, where I tried to implement the constraint 'x[5]<0.2'. But the code ran forever and failed to output any candidates or observations. It was working well without the two constraints. Did I mess up anything here? Thank you.

    Code example

    def get_mfkg(model):
        curr_val_acqf = FixedFeatureAcquisitionFunction(
            acq_function=PosteriorMean(model),
            d=7,
            columns=[6],
            values=[1],
        )
        
        _, current_value = optimize_acqf(
            acq_function=curr_val_acqf,
            bounds=bounds[:,:-1],
            q=1,
            num_restarts=10 if not SMOKE_TEST else 2,
            raw_samples=1024 if not SMOKE_TEST else 4,
            options={"batch_limit": 10, "maxiter": 200},
            inequality_constraints=[(torch.tensor([5]),torch.tensor([-1]),-0.2)],
        )
            
        return qMultiFidelityKnowledgeGradient(
            model=model,
            num_fantasies=128 if not SMOKE_TEST else 2,
            current_value=current_value,
            cost_aware_utility=cost_aware_utility,
            project=project,
        )
    
    def optimize_mfkg_and_get_observation(mfkg_acqf):
        """Optimizes MFKG and returns a new candidate, observation, and cost."""
        
        X_init = gen_one_shot_kg_initial_conditions(
            acq_function = mfkg_acqf,
            bounds=bounds,
            q=4,
            num_restarts=10,
            raw_samples=512,
        )
        candidates, _ = optimize_acqf_mixed(
            acq_function=mfkg_acqf,
            bounds=bounds,
            fixed_features_list=[{6: 0.0}, {6: 1.0}], 
            q=1,
            num_restarts=NUM_RESTARTS,
            raw_samples=RAW_SAMPLES,
            batch_initial_conditions=X_init,
            options={"batch_limit": 5, "maxiter": 200},
            inequality_constraints=[(torch.tensor([5]),torch.tensor([-1]),-0.2)],
        )
        cost = cost_model(candidates).sum()
        new_x = candidates.detach()
        new_obj = problem(new_x).unsqueeze(-1)
        print(f"candidates:\n{new_x}\n")
        print(f"observations:\n{new_obj}\n\n")
        return new_x, new_obj, cost
    

    note that the discrete fidelities were slightly modified from the original page.

    System Info

    Please provide information about your setup, including

    • BoTorch Version 0.6.0
    • GPyTorch Version 1.6.0
    • PyTorch Version 1.10.0
    • mac OS Mojave Version 10.14.6
    opened by shangzhu-cmu 3
  • Update tutorials to use

    Update tutorials to use "sample_around_best": True

    Motivation

    Using "sample_around_best": True should lead to improved optimization performance.

    Have you read the Contributing Guidelines on pull requests?

    Yest

    Test Plan

    TODO: Re-run the notebooks, so the outputs reflect the changes.

    Related PRs

    (If this PR adds or changes functionality, please take some time to update the docs at https://github.com/pytorch/botorch, and link to your PR here.)

    cc @sdaulton

    CLA Signed 
    opened by saitcakmak 6
  • Non GP model types in Botorch

    Non GP model types in Botorch

    Hi,

    I was thinking about the possibility to use non GP models within botorch. For example to use a GP for one objective and a neural network (ensemble) for another one. Using just a neural network should already be possible via the GenericDeterministcModel https://github.com/pytorch/botorch/blob/f8da711049161f3dc238ada2890963b6c6dbb8ee/botorch/models/deterministic.py#L83 via just hooking in a neural network written in torch as callable f.

    In this case, uncertainty estimates from a NN ensemble could not be used. My idea was to implement a new type of Posterior that takes also the variance from an NN ensemble and return it as variance of the posterior. https://github.com/pytorch/botorch/blob/f8da711049161f3dc238ada2890963b6c6dbb8ee/botorch/posteriors/posterior.py#L56

    This should it already allow to use the whole botorch machinery of analytical acquisition functions. Of course this assumes that the posterior is normally distributed. If one then also implements the rsample method of the posterior, then one should also be able to use the MC acquisiton functions.

    Do you see any obstacles in this?

    I see the benefit in the possibility of using other model types in situations in which they perform better than GPs and do not have to reimplement the great machinere of acquisition functions and so forth, which are already available in botorch.

    Best,

    Johannes

    opened by jduerholt 6
  • Implementation of MORBO algorithm

    Implementation of MORBO algorithm

    Hi, first of all many thanks for such a great and useful library. I am using Botorch for engineering design optimisation combined with CFD simulations and absolutely loving it. I had two requests which I believe can be very useful to the community:

    1. Any chance of implementing MORBO algorithm (possibly with tutorials on how to set it up). I noted from NeurIPS paper that you are planning to release this as well.
    2. The tutorial for TuRBO and the paper does not take into account constraints. Is it possible to handle constraint optimisation with TuRBO? Many thanks
    enhancement 
    opened by RafieeAshkan 3
  • Transforms in MixedSingleTaskGP

    Transforms in MixedSingleTaskGP

    Hi,

    I saw the implemention of a MixedSingleTaskGP with the combination of a continuous and a categorical kernel to overcome problems with one hot encodings and I really like it.

    I was just wondering if input and output transforms are working with this kind of GP as they are commented out in the docstring and marked with "todo" in the __init__ method https://github.com/pytorch/botorch/blob/51b3202dcccf2a1356649c512df4caf77cd91c33/botorch/models/gp_regression_mixed.py#L56). Nevertheless, one can provide transforms and they are also parsed to the constructor of the "SingleTaskGP" class form which MixedSingleTaskGP is inherited from.

    So my question is: Do you expect that the MixedSingleTaskGP is working with transforms?

    Best,

    Johannes

    opened by jduerholt 9
  • [Bug] `get_polytope_samples` returns unfeasible samples

    [Bug] `get_polytope_samples` returns unfeasible samples

    ๐Ÿ› Bug

    When generating samples with get_polytope_samples for a constrained problem that is determined in some dimensions (e.g. there is only one solution on that dimension), the function returns samples that don't satisfy the constraints.

    To reproduce

    >>> from botorch.utils.sampling import get_polytope_samples
    >>> import torch
    
    >>> bounds = torch.tensor([[0,0,0],[10,10,10]]).double() # 3-dimensional space
    
    # This doesn't satisfy the constraint
    >>> constraint = (torch.tensor([0,1]).double(),torch.tensor([1,1]),20) # dim 0,1 have to be 10 to satisfy the constraint
    >>> get_polytope_samples(1,bounds,inequality_constraints=[constraint])
    tensor([[8.2054, 2.7486, 4.8757]], dtype=torch.float64)
    
    # This works fine
    >>> constraint = (torch.tensor([0,1]).double(),torch.tensor([1,1]),19.9) # There is some freedom
    >>> get_polytope_samples(1,bounds,inequality_constraints=[constraint])
    tensor([[9.1134, 9.9935, 0.4924]], dtype=torch.float64)
    

    Stack trace/error message

    I'm getting this warning the first time I run get_polytope_samples:

    .venv/lib/python3.8/site-packages/botorch/utils/sampling.py:471: OptimizeWarning: Solving system with option 'cholesky':True failed. It is normal for this to happen occasionally, especially as the solution is approached. However, if you see this frequently, consider setting option 'cholesky' to False.
      result = scipy.optimize.linprog(c=c, A_ub=A_ub, b_ub=b_ub, A_eq=A_eq, b_eq=b_eq)
    .venv/lib/python3.8/site-packages/botorch/utils/sampling.py:471: OptimizeWarning: Solving system with option 'sym_pos':True failed. It is normal for this to happen occasionally, especially as the solution is approached. However, if you see this frequently, consider setting option 'sym_pos' to False.
      result = scipy.optimize.linprog(c=c, A_ub=A_ub, b_ub=b_ub, A_eq=A_eq, b_eq=b_eq)
    .venv/lib/python3.8/site-packages/scipy/optimize/_linprog_ip.py:117: LinAlgWarning: Ill-conditioned matrix (rcond=1.9303e-18): result may not be accurate.
      return sp.linalg.solve(M, r, sym_pos=sym_pos)
    

    Expected Behavior

    The constraint is feasible so a point that satisfies the constraint should be returned.

    System information

    Please complete the following information:

    • Botorch: 0.6
    • GPyTorch: 1.6.0
    • PyTorch:1.10.1
    • Computer OS: MacOS 12.0.1
    bug 
    opened by yoavnavon 7
  • [Feature Request] FilterFeatures InputTransform

    [Feature Request] FilterFeatures InputTransform

    ๐Ÿš€ Feature Request

    For multiobjective optimization in which it is known in advance that a feature has no impact on one of the objectives but on the others, it can be useful to build a ModelListGP model in which the specific models have different subsets of input features. This amounts to a kind of feature selection scenario.

    Motivation

    Look above.

    Pitch

    This is my current solution for this kind of problems. I think it is general applicable and could be useful.

    class FilterFeatures(InputTransform, Module):
        
        def __init__(
            self,
            indices: Tensor,
            transform_on_train: bool = True,
            transform_on_eval: bool = True,
            transform_on_fantasize: bool = True,
            transform_on_preprocess: bool = False,
        ) -> None:
            super().__init__()
            self.transform_on_train = transform_on_train
            self.transform_on_eval = transform_on_eval
            self.transform_on_fantasize: bool = True
            self.transform_on_preprocess = transform_on_preprocess
            self.register_buffer("indices", indices)
            
        def transform(self, X: Tensor) -> Tensor:
            return X[...,self.indices]
        
        def equals(self, other: InputTransform) -> bool:
            r"""Check if another input transform is equivalent.
    
            Args:
                other: Another input transform
    
            Returns:
                A boolean indicating if the other transform is equivalent.
            """
            return (
                super().equals(other=other)
                and self.indices == other.indices
            )
    

    Additional context

    It would be used in combination with a ModelListGP in which those models in which features should be filtered out are using this kind of FilterFeatures input transform.

    enhancement 
    opened by jduerholt 2
  • [Bug] Parsing an emtpy dictionary as fixed_features to optimize_acqf

    [Bug] Parsing an emtpy dictionary as fixed_features to optimize_acqf

    ๐Ÿ› Bug

    I would expect that parsing an empty dictionary as fixed_features in optimize_acqf would result in the same as parsing None. But the empty dictionary results in an error. Fixing it should be easy. Just add the line

    if len(fixed_features)==0: REDUCED=False
    

    at line 92 of gen.py (https://github.com/pytorch/botorch/blob/main/botorch/generation/gen.py#L92)

    To reproduce

    ** Code snippet to reproduce **

    import torch
    from botorch.models import SingleTaskGP
    from botorch.fit import fit_gpytorch_model
    from botorch.utils import standardize
    from gpytorch.mlls import ExactMarginalLogLikelihood
    from botorch.acquisition import UpperConfidenceBound
    from botorch.optim import optimize_acqf
    
    train_X = torch.rand(10, 2)
    Y = 1 - torch.norm(train_X - 0.5, dim=-1, keepdim=True)
    Y = Y + 0.1 * torch.randn_like(Y)  # add some noise
    train_Y = standardize(Y)
    
    gp = SingleTaskGP(train_X, train_Y)
    mll = ExactMarginalLogLikelihood(gp.likelihood, gp)
    fit_gpytorch_model(mll)
    
    UCB = UpperConfidenceBound(gp, beta=0.1)
    
    bounds = torch.stack([torch.zeros(2), torch.ones(2)])
    candidate, acq_value = optimize_acqf(
        UCB, bounds=bounds, q=1, num_restarts=5, raw_samples=20,fixed_features={}
    )
    print(candidate)
    

    ** Stack trace/error message **

    Traceback (most recent call last):
      File "mwe.py", line 22, in <module>
        UCB, bounds=bounds, q=1, num_restarts=5, raw_samples=20,fixed_features={}
      File "C:\ProgramData\Anaconda3\envs\aichembuddy2\lib\site-packages\botorch\optim\optimize.py", line 210, in optimize_acqf
        fixed_features=fixed_features,
      File "C:\ProgramData\Anaconda3\envs\aichembuddy2\lib\site-packages\botorch\generation\gen.py", line 104, in gen_candidates_scipy
        equality_constraints=equality_constraints,
      File "C:\ProgramData\Anaconda3\envs\aichembuddy2\lib\site-packages\botorch\generation\utils.py", line 120, in _remove_fixed_features_from_optimization
        values=sorted_values,
      File "C:\ProgramData\Anaconda3\envs\aichembuddy2\lib\site-packages\botorch\acquisition\fixed_feature.py", line 99, in __init__
        new_values = torch.cat(torch.broadcast_tensors(*new_values), dim=-1)
    NotImplementedError: There were no tensor arguments to this function (e.g., you passed an empty list of Tensors), but no fallback function is registered for schema aten::_cat.  This usually means that this function requires a non-empty list of Tensors, or that you (the operator writer) forgot to register a fallback function.  Available functions are [CPU, CUDA, QuantizedCPU, BackendSelect, Named, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, UNKNOWN_TENSOR_TYPE_ID, AutogradMLC, AutogradHPU, AutogradNestedTensor, AutogradPrivateUse1, AutogradPrivateUse2, AutogradPrivateUse3, Tracer, Autocast, Batched, VmapMode].
    
    CPU: registered at aten\src\ATen\RegisterCPU.cpp:16286 [kernel]
    CUDA: registered at aten\src\ATen\RegisterCUDA.cpp:20674 [kernel]
    QuantizedCPU: registered at aten\src\ATen\RegisterQuantizedCPU.cpp:1025 [kernel]
    BackendSelect: fallthrough registered at ..\aten\src\ATen\core\BackendSelectFallbackKernel.cpp:3 [backend fallback]
    Named: registered at ..\aten\src\ATen\core\NamedRegistrations.cpp:7 [backend fallback]
    ADInplaceOrView: fallthrough registered at ..\aten\src\ATen\core\VariableFallbackKernel.cpp:60 [backend fallback]
    AutogradOther: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradCPU: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradCUDA: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradXLA: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    UNKNOWN_TENSOR_TYPE_ID: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradMLC: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradHPU: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradNestedTensor: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradPrivateUse1: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradPrivateUse2: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    AutogradPrivateUse3: registered at ..\torch\csrc\autograd\generated\VariableType_2.cpp:9928 [autograd kernel]
    Tracer: registered at ..\torch\csrc\autograd\generated\TraceType_2.cpp:9621 [kernel]
    Autocast: registered at ..\aten\src\ATen\autocast_mode.cpp:259 [kernel]
    Batched: registered at ..\aten\src\ATen\BatchingRegistrations.cpp:1019 [backend fallback]
    VmapMode: fallthrough registered at ..\aten\src\ATen\VmapModeRegistrations.cpp:33 [backend fallback]
    

    Expected Behavior

    I would expect the same behavior as parsing None as fixed_features.

    System information

    • botorch: 0.6.0
    • gyptorch: 1.6.0
    • pytorch: 1.9.1
    • OS: Windows
    bug 
    opened by jduerholt 1
  • [Feature Request] Add an input constructor for qNegIntegratedPosteriorVariance

    [Feature Request] Add an input constructor for qNegIntegratedPosteriorVariance

    ๐Ÿš€ Feature Request

    Add an input constructor for qNegIntegratedPosteriorVariance.

    Motivation

    I'd like to use qNegIntegratedPosteriorVariance with Ax and its BoTorch model bridge, but to do so I need the qNegIntegratedPosteriorVariance acquisition function to be added to botorch/acquisition/input_constructors.py.

    Are you willing to open a pull request? (See CONTRIBUTING)

    I have a very rough solution to this, but would appreciate some guidance on how to go about it properly. Thanks so much for all your efforts!

    enhancement 
    opened by samueljamesbell 1
Releases(v0.6.2)
  • v0.6.2(Mar 9, 2022)

    New Features

    • Use BOTORCH_MODULAR in tutorials with Ax (#1105).
    • Add optimize_acqf_discrete_local_search for discrete search spaces (#1111).

    Bug Fixes

    • Fix missing posterior_transform in qNEI and get_acquisition_function (#1113).
    Source code(tar.gz)
    Source code(zip)
  • v0.6.1(Feb 28, 2022)

    New Features

    • Add Standardize input transform (#1053).
    • Low-rank Cholesky updates for NEI (#1056).
    • Add support for non-linear input constraints (#1067).
    • New MOO problems: MW7 (#1077), disc brake (#1078), penicillin (#1079), RobustToy (#1082), GMM (#1083).

    Other Changes

    • Add Dispatcher (#1009).
    • Modify qNEHVI to support deterministic models (#1026).
    • Store tensor attributes of input transforms as buffers (#1035).
    • Modify NEHVI to support MTGPs (#1037).
    • Make Normalize input transform input column-specific (#1047).
    • Improve find_interior_point (#1049).
    • Remove deprecated botorch.distributions module (#1061).
    • Avoid costly application of posterior transform in Kronecker & HOGP models (#1076).
    • Support heteroscedastic perturbations in InputPerturbations (#1088).

    Performance Improvements

    • Make risk measures more memory efficient (#1034).

    Bug Fixes

    • Properly handle empty fixed_features in optimization (#1029).
    • Fix missing weights in VaR risk measure (#1038).
    • Fix find_interior_point for negative variables & allow unbounded problems (#1045).
    • Filter out indefinite bounds in constraint utilities (#1048).
    • Make non-interleaved base samples use intuitive shape (#1057).
    • Pad small diagonalization with zeros for KroneckerMultitaskGP (#1071).
    • Disable learning of bounds in preprocess_transform (#1089).
    • Catch runtime errors with ill-conditioned covar (#1095).
    • Fix compare_mc_analytic_acquisition tutorial (#1099).
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Dec 9, 2021)

    Compatibility

    • Require PyTorch >=1.9 (#1011).
    • Require GPyTorch >=1.6 (#1011).

    New Features

    • New ApproximateGPyTorchModel wrapper for various (variational) approximate GP models (#1012).
    • New SingleTaskVariationalGP stochastic variational Gaussian Process model (#1012).
    • Support for Multi-Output Risk Measures (#906, #965).
    • Introduce ModelList and PosteriorList (#829).
    • New Constraint Active Search tutorial (#1010).
    • Add additional multi-objective optimization test problems (#958).

    Other Changes

    • Add covar_module as an optional input of MultiTaskGP models (#941).
    • Add min_range argument to Normalize transform to prevent division by zero (#931).
    • Add initialization heuristic for acquisition function optimization that samples around best points (#987).
    • Update initialization heuristic to perturb a subset of the dimensions of the best points if the dimension is > 20 (#988).
    • Modify apply_constraints utility to work with multi-output objectives (#994).
    • Short-cut t_batch_mode_transform decorator on non-tensor inputs (#991).

    Performance Improvements

    • Use lazy covariance matrix in BatchedMultiOutputGPyTorchModel.posterior (#976).
    • Fast low-rank Cholesky updates for qNoisyExpectedHypervolumeImprovement (#747, #995, #996).

    Bug Fixes

    • Update error handling to new PyTorch linear algebra messages (#940).
    • Avoid test failures on Ampere devices (#944).
    • Fixes to the Griewank test function (#972).
    • Handle empty base_sample_shape in Posterior.rsample (#986).
    • Handle NotPSDError and hitting maxiter in fit_gpytorch_model (#1007).
    • Use TransformedPosterior for subclasses of GPyTorchPosterior (#983).
    • Propagate best_f argument to qProbabilityOfImprovement in input constructors (f5a5f8b6dc20413e67c6234e31783ac340797a8d)
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(Sep 2, 2021)

    Compatibility

    • Require GPyTorch >=1.5.1 (#928).

    New Features

    • Add HigherOrderGP composite Bayesian Optimization tutorial notebook (#864).
    • Add Multi-Task Bayesian Optimization tutorial (#867).
    • New multi-objective test problems from (#876).
    • Add PenalizedMCObjective and L1PenaltyObjective (#913).
    • Add a ProximalAcquisitionFunction for regularizing new candidates towards previously generated ones (#919, #924).
    • Add a Power outcome transform (#925).

    Bug Fixes

    • Batch mode fix for HigherOrderGP initialization (#856).
    • Improve CategoricalKernel precision (#857).
    • Fix an issue with qMultiFidelityKnowledgeGradient.evaluate (#858).
    • Fix an issue with transforms with HigherOrderGP. (#889)
    • Fix initial candidate generation when parameter constraints are on different device (#897).
    • Fix bad in-place op in _generate_unfixed_lin_constraints (#901).
    • Fix an input transform bug in fantasize call (#902).
    • Fix outcome transform bug in batched_to_model_list (#917).

    Other Changes

    • Make variance optional for TransformedPosterior.mean (#855).
    • Support transforms in DeterministicModel (#869).
    • Support batch_shape in RandomFourierFeatures (#877).
    • Add a maximize flag to PosteriorMean (#881).
    • Ignore categorical dimensions when validating training inputs in MixedSingleTaskGP (#882).
    • Refactor HigherOrderGPPosterior for memory efficiency (#883).
    • Support negative weights for minimization objectives in get_chebyshev_scalarization (#884).
    • Move train_inputs transforms to model.train/eval calls (#894).
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jun 29, 2021)

    Compatibility

    • Require PyTorch >=1.8.1 (#832).
    • Require GPyTorch >=1.5 (#848).
    • Changes to how input transforms are applied: transform_inputs is applied in model.forward if the model is in train mode, otherwise it is applied in the posterior call (#819, #835).

    New Features

    • Improved multi-objective optimization capabilities:
      • qNoisyExpectedHypervolumeImprovement acquisition function that improves on qExpectedHypervolumeImprovement in terms of tolerating observation noise and speeding up computation for large q-batches (#797, #822).
      • qMultiObjectiveMaxValueEntropy acqusition function (913aa0e510dde10568c2b4b911124cdd626f6905, #760).
      • Heuristic for reference point selection (#830).
      • FastNondominatedPartitioning for Hypervolume computations (#699).
      • DominatedPartitioning for partitioning the dominated space (#726).
      • BoxDecompositionList for handling box decompositions of varying sizes (#712).
      • Direct, batched dominated partitioning for the two-outcome case (#739).
      • get_default_partitioning_alpha utility providing heuristic for selecting approximation level for partitioning algorithms (#793).
      • New method for computing Pareto Frontiers with less memory overhead (#842, #846).
    • New qLowerBoundMaxValueEntropy acquisition function (a.k.a. GIBBON), a lightweight variant of Multi-fidelity Max-Value Entropy Search using a Determinantal Point Process approximation (#724, #737, #749).
    • Support for discrete and mixed input domains:
      • CategoricalKernel for categorical inputs (#771).
      • MixedSingleTaskGP for mixed search spaces (containing both categorical and ordinal parameters) (#772, #847).
      • optimize_acqf_discrete for optimizing acquisition functions over fully discrete domains (#777).
      • Extend optimize_acqf_mixed to allow batch optimization (#804).
    • Support for robust / risk-aware optimization:
      • Risk measures for robust / risk-averse optimization (#821).
      • AppendFeatures transform (#820).
      • InputPerturbation input transform for for risk averse BO with implementation errors (#827).
      • Tutorial notebook for Bayesian Optimization of risk measures (#823).
      • Tutorial notebook for risk-averse Bayesian Optimization under input perturbations (#828).
    • More scalable multi-task modeling and sampling:
      • KroneckerMultiTaskGP model for efficient multi-task modeling for block-design settings (all tasks observed at all inputs) (#637).
      • Support for transforms in Multi-Task GP models (#681).
      • Posterior sampling based on Matheron's rule for Multi-Task GP models (#841).
    • Various changes to simplify and streamline integration with Ax:
      • Handle non-block designs in TrainingData (#794).
      • Acquisition function input constructor registry (#788, #802, #845).
    • Random Fourier Feature (RFF) utilties for fast (approximate) GP function sampling (#750).
    • DelaunayPolytopeSampler for fast uniform sampling from (simple) polytopes (#741).
    • Add evaluate method to ScalarizedObjective (#795).

    Bug Fixes

    • Handle the case when all features are fixed in optimize_acqf (#770).
    • Pass fixed_features to initial candidate generation functions (#806).
    • Handle batch empty pareto frontier in FastPartitioning (#740).
    • Handle empty pareto set in is_non_dominated (#743).
    • Handle edge case of no or a single observation in get_chebyshev_scalarization (#762).
    • Fix an issue in gen_candidates_torch that caused problems with acqusition functions using fantasy models (#766).
    • Fix HigherOrderGP dtype bug (#728).
    • Normalize before clamping in Warp input warping transform (#722).
    • Fix bug in GP sampling (#764).

    Other Changes

    • Modify input transforms to support one-to-many transforms (#819, #835).
    • Make initial conditions for acquisition function optimization honor parameter constraints (#752).
    • Perform optimization only over unfixed features if fixed_features is passed (#839).
    • Refactor Max Value Entropy Search Methods (#734).
    • Use Linear Algebra functions from the torch.linalg module (#735).
    • Use PyTorch's Kumaraswamy distribution (#746).
    • Improved capabilities and some bugfixes for batched models (#723, #767).
    • Pass callback argument to scipy.optim.minimize in gen_candidates_scipy (#744).
    • Modify behavior of X_pending in in multi-objective acqusiition functions (#747).
    • Allow multi-dimensional batch shapes in test functions (#757).
    • Utility for converting batched multi-output models into batched single-output models (#759).
    • Explicitly raise NotPSDError in _scipy_objective_and_grad (#787).
    • Make raw_samples optional if batch_initial_conditions is passed (#801).
    • Use powers of 2 in qMC docstrings & examples (#812).
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Feb 23, 2021)

    Compatibility

    • Require PyTorch >=1.7.1 (#714).
    • Require GPyTorch >=1.4 (#714).

    New Features

    • HigherOrderGP - High-Order Gaussian Process (HOGP) model for high-dimensional output regression (#631, #646, #648, #680).
    • qMultiStepLookahead acquisition function for general look-ahead optimization approaches (#611, #659).
    • ScalarizedPosteriorMean and project_to_sample_points for more advanced MFKG functionality (#645).
    • Large-scale Thompson sampling tutorial (#654, #713).
    • Tutorial for optimizing mixed continuous/discrete domains (application to multi-fidelity KG with discrete fidelities) (#716).
    • GPDraw utility for sampling from (exact) GP priors (#655).
    • Add X as optional arg to call signature of MCAcqusitionObjective (#487).
    • OSY synthetic test problem (#679).

    Bug Fixes

    • Fix matrix multiplication in scalarize_posterior (#638).
    • Set X_pending in get_acquisition_function in qEHVI (#662).
    • Make contextual kernel device-aware (#666).
    • Do not use an MCSampler in MaxPosteriorSampling (#701).
    • Add ability to subset outcome transforms (#711).

    Performance Improvements

    • Batchify box decomposition for 2d case (#642).

    Other Changes

    • Use scipy distribution in MES quantile bisect (#633).
    • Use new closure definition for GPyTorch priors (#634).
    • Allow enabling of approximate root decomposition in posterior calls (#652).
    • Support for upcoming 21201-dimensional PyTorch SobolEngine (#672, #674).
    • Refactored various MOO utilities to allow future additions (#656, #657, #658, #661).
    • Support input_transform in PairwiseGP (#632).
    • Output shape checks for t_batch_mode_transform (#577).
    • Check for NaN in gen_candidates_scipy (#688).
    • Introduce base_sample_shape property to Posterior objects (#718).
    Source code(tar.gz)
    Source code(zip)
  • v0.3.3(Dec 8, 2020)

    Compatibility

    • Require PyTorch >=1.7 (#614).
    • Require GPyTorch >=1.3 (#614).

    New Features

    Bug fixes

    • Fix bounds of HolderTable synthetic function (#596).
    • Fix device issue in MOO tutorial (#621).

    Other changes

    • Add train_inputs option to qMaxValueEntropy (#593).
    • Enable gpytorch settings to override BoTorch defaults for fast_pred_var and debug (#595).
    • Rename set_train_data_transform -> preprocess_transform (#575).
    • Modify _expand_bounds() shape checks to work with >2-dim bounds (#604).
    • Add batch_shape property to models (#588).
    • Modify qMultiFidelityKnowledgeGradient.evaluate() to work with project, expand and cost_aware_utility (#594).
    • Add list of papers using BoTorch to website docs (#617).
    Source code(tar.gz)
    Source code(zip)
  • v0.3.2(Oct 26, 2020)

    New Features

    • Add PenalizedAcquisitionFunction wrapper (#585)
    • Input transforms
      • Reversible input transform (#550)
      • Rounding input transform (#562)
      • Log input transform (#563)
    • Differentiable approximate rounding for integers (#561)

    Bug fixes

    • Fix sign error in UCB when maximize=False (a4bfacbfb2109d3b89107d171d2101e1995822bb)
    • Fix batch_range sample shape logic (#574)

    Other changes

    • Better support for two stage sampling in preference learning (0cd13d0cb49b1ac8d0971e42f1f0e9dd6126fd9a)
    • Remove noise term in PairwiseGP and add ScaleKernel by default (#571)
    • Rename prior to task_covar_prior in MultiTaskGP and FixedNoiseMultiTaskGP (16573fea066d8bb682dc68526f42b6ec7c22a555)
    • Support only transforming inputs on training or evaluation (#551)
    • Add equals method for InputTransform (#552)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Sep 16, 2020)

    New Features

    • Constrained Multi-Objective tutorial (#493)
    • Multi-fidelity Knowledge Gradient tutorial (#509)
    • Support for batch qMC sampling (#510)
    • New evaluate method for qKnowledgeGradient (#515)

    Compatibility

    • Require PyTorch >=1.6 (#535)
    • Require GPyTorch >=1.2 (#535)
    • Remove deprecated botorch.gen module (#532)

    Bug fixes

    • Fix bad backward-indexing of task_feature in MultiTaskGP (#485)
    • Fix bounds in constrained Branin-Currin test function (#491)
    • Fix max_hv for C2DTLZ2 and make Hypervolume always return a float (#494)
    • Fix bug in draw_sobol_samples that did not use the proper effective dimension (#505)
    • Fix constraints for q>1 in qExpectedHypervolumeImprovement (c80c4fdb0f83f0e4f12e4ec4090d0478b1a8b532)
    • Only use feasible observations in partitioning for qExpectedHypervolumeImprovement in get_acquisition_function (#523)
    • Improved GPU compatibility for PairwiseGP (#537)

    Performance Improvements

    • Reduce memory footprint in qExpectedHypervolumeImprovement (#522)
    • Add (q)ExpectedHypervolumeImprovement to nonnegative functions [for better initialization] (#496)

    Other changes

    • Support batched best_f in qExpectedImprovement (#487)
    • Allow to return full tree of solutions in OneShotAcquisitionFunction (#488)
    • Added construct_inputs class method to models to programmatically construct the inputs to the constructor from a standardized TrainingData representation (#477, #482, 3621198d02195b723195b043e86738cd5c3b8e40)
    • Acquisition function constructors now accept catch-all **kwargs options (#478, e5b69352954bb10df19a59efe9221a72932bfe6c)
    • Use psd_safe_cholesky in qMaxValueEntropy for better numerical stabilty (#518)
    • Added WeightedMCMultiOutputObjective (81d91fd2e115774e561c8282b724457233b6d49f)
    • Add ability to specify outcomes to all multi-output objectives (#524)
    • Return optimization output in info_dict for fit_gpytorch_scipy (#534)
    • Use setuptools_scm for versioning (#539)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Jul 6, 2020)

    New Features

    • Multi-Objective Acquisition Functions (#466)
      • q-Expected Hypervolume Improvement
      • q-ParEGO
      • Analytic Expected Hypervolume Improvement with auto-differentiation
    • Multi-Objective Utilities (#466)
      • Pareto Computation
      • Hypervolume Calculation
      • Box Decomposition algorithm
    • Multi-Objective Test Functions (#466)
      • Suite of synthetic test functions for multi-objective, constrained optimzation
    • Multi-Objective Tutorial (#468)
    • Abstract ConstrainedBaseTestProblem (#454)
    • Add optimize_acqf_list method for sequentially, greedily optimizing 1 candidate from each provided acquisition function (d10aec911b241b208c59c192beb9e4d572a092cd)

    Bug fixes

    • Fixed re-arranging mean in MultiTask multi-output models (#450).

    Other changes

    • Move gpt_posterior_settings into models.utils (#449)
    • Allow specifications of batch dims to collapse in samplers (#457)
    • Remove outcome transform before model-fitting for sequential model fitting in multi-output models (#458)
    Source code(tar.gz)
    Source code(zip)
  • v0.2.5(May 14, 2020)

  • v0.2.4(May 13, 2020)

    Bug fixes

    • There was a mysterious issue with the 0.2.3 wheel on pypi, where part of the botorch/optim/utils.py file was not included, which resulted in an ImportError for many central components of the code. Interestingly, the source dist (built with the same command) did not have this issue.
    • Preserve order in ChainedOutcomeTransform (#440).

    New Features

    • Utilities for estimating the feasible volume under outcome constraints (#437).
    Source code(tar.gz)
    Source code(zip)
  • v0.2.3(Apr 26, 2020)

    Introduces a new Pairwise GP model for Preference Learning with pair-wise preferential feedback, as well as a Sampling Strategies abstraction for generating candidates from a discrete candidate set.

    Compatibility

    • Require PyTorch >=1.5 (#423).
    • Require GPyTorch >=1.1.1 (#425).

    New Features

    • Add PairwiseGP for preference learning with pair-wise comparison data (#388).
    • Add SamplingStrategy abstraction for sampling-based generation strategies, including MaxPosteriorSampling (i.e. Thompson Sampling) and BoltzmannSampling (#218, #407).

    Deprecations

    • The existing botorch.gen module is moved to botorch.generation.gen and imports from botorch.gen will raise a warning (an error in the next release) (#218).

    Bug fixes

    • Fix & update a number of tutorials (#394, #398, #393, #399, #403).
    • Fix CUDA tests (#404).
    • Fix sobol maxdim limitation in prune_baseline (#419).

    Other changes

    • Better stopping criteria for stochastic optimization (#392).
    • Improve numerical stability of LinearTruncatedFidelityKernel (#409).
    • Allow batched best_f in qExpectedImprovement and qProbabilityOfImprovement (#411).
    • Introduce new logger framework (#412).
    • Faster indexing in some situations (#414).
    • More generic BaseTestProblem (9e604fe2188ac85294c143d249872415c4d95823).
    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Mar 9, 2020)

    Require Python 3.7 and adds new features for active learning and multi-fidelity optimization, along with a number of bug fixes.

    Compatibility

    • Require PyTorch >=1.4 (#379).
    • Require Python >=3.7 (#378).

    New Features

    • Add qNegIntegratedPosteriorVariance for Bayesian active learning (#377).
    • Add FixedNoiseMultiFidelityGP, analogous to SingleTaskMultiFidelityGP (#386).
    • Support scalarize_posterior for m>1 and q>1 posteriors (#374).
    • Support subset_output method on multi-fidelity models (#372).
    • Add utilities for sampling from simplex and hypersphere (#369).

    Bug fixes

    • Fix TestLoader local test discovery (#376).
    • Fix batch-list conversion of SingleTaskMultiFidelityGP (#370).
    • Validate tensor args before checking input scaling for more informative error messaages (#368).
    • Fix flaky qNoisyExpectedImprovement test (#362).
    • Fix test function in closed-loop tutorial (#360).
    • Fix num_output attribute in BoTorch/Ax tutorial (#355).

    Other changes

    • Require output dimension in MultiTaskGP (#383).
    • Update code of conduct (#380).
    • Remove deprecated joint_optimize and sequential_optimize (#363).
    Source code(tar.gz)
    Source code(zip)
  • v0.2.1(Jan 16, 2020)

    Minor bug fix release.

    New Features

    • Add a static method for getting batch shapes for batched MO models (#346).

    Bug fixes

    • Revamp qKG constructor to avoid issue with missing objective (#351).
    • Make sure MVES can support sampled costs like KG (#352).

    Other changes

    • Allow custom module-to-array handling in fit_gpytorch_scipy (#341).
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Dec 20, 2019)

    This release adds the popular Max-value Entropy Search (MES) acquisition function, as well as support for multi-fidelity Bayesian optimization via both the Knowledge Gradient (KG) and MES.

    Compatibility

    • Require PyTorch >=1.3.1 (#313).
    • Require GPyTorch >=1.0 (#342).

    New Features

    • Add cost-aware KnowledgeGradient (qMultiFidelityKnowledgeGradient) for multi-fidelity optimization (#292).
    • Add qMaxValueEntropy and qMultiFidelityMaxValueEntropy max-value entropy search acquisition functions (#298).
    • Add subset_output functionality to (most) models (#324).
    • Add outcome transforms and input transforms (#321).
    • Add outcome_transform kwarg to model constructors for automatic outcome transformation and un-transformation (#327).
    • Add cost-aware utilities for cost-sensitive acquisiiton functions (#289).
    • Add DeterminsticModel and DetermisticPosterior abstractions (#288).
    • Add AffineFidelityCostModel (f838eacb4258f570c3086d7cbd9aa3cf9ce67904).
    • Add project_to_target_fidelity and expand_trace_observations utilities for use in multi-fidelity optimization (1ca12ac0736e39939fff650cae617680c1a16933).

    Performance Improvements

    • New prune_baseline option for pruning X_baseline in qNoisyExpectedImprovement (#287).
    • Do not use approximate MLL computation for deterministic fitting (#314).
    • Avoid re-evaluating the acquisition function in gen_candidates_torch (#319).
    • Use CPU where possible in gen_batch_initial_conditions to avoid memory issues on the GPU (#323).

    Bug fixes

    • Properly register NoiseModelAddedLossTerm in HeteroskedasticSingleTaskGP (671c93a203b03ef03592ce322209fc5e71f23a74).
    • Fix batch mode for MultiTaskGPyTorchModel (#316).
    • Honor propagate_grads argument in fantasize of FixedNoiseGP (#303).
    • Properly handle diag arg in LinearTruncatedFidelityKernel (#320).

    Other changes

    • Consolidate and simplify multi-fidelity models (#308).
    • New license header style (#309).
    • Validate shape of best_f in qExpectedImprovement (#299).
    • Support specifying observation noise explicitly for all models (#256).
    • Add num_outputs property to the Model API (#330).
    • Validate output shape of models upon instantiating acquisition functions (#331).

    Tests

    • Silence warnings outside of explicit tests (#290).
    • Enforce full sphinx docs coverage in CI (#294).
    Source code(tar.gz)
    Source code(zip)
  • v0.1.4(Oct 2, 2019)

    Breaking Changes

    • Require explicit output dimensions in BoTorch models (#238)
    • Make joint_optimize / sequential_optimize return acquisition function values (#149) [note deprecation notice below]
    • standardize now works on the second to last dimension (#263)
    • Refactor synthetic test functions (#273)

    New Features

    • Add qKnowledgeGradient acquisition function (#272, #276)
    • Add input scaling check to standard models (#267)
    • Add cyclic_optimize, convergence criterion class (#269)
    • Add settings.debug context manager (#242)

    Deprecations

    • Consolidate sequential_optimize and joint_optimize into optimize_acqf (#150)

    Bug fixes

    • Properly pass noise levels to GPs using a FixedNoiseGaussianLikelihood (#241) [requires gpytorch > 0.3.5]
    • Fix q-batch dimension issue in ConstrainedExpectedImprovement (6c067185f56d3a244c4093393b8a97388fb1c0b3)
    • Fix parameter constraint issues on GPU (#260)

    Minor changes

    • Add decorator for concatenating pending points (#240)
    • Draw independent sample from prior for each hyperparameter (#244)
    • Allow dim > 1111 for gen_batch_initial_conditions (#249)
    • Allow optimize_acqf to use q>1 for AnalyticAcquisitionFunction (#257)
    • Allow excluding parameters in fit functions (#259)
    • Track the final iteration objective value in fit_gpytorch_scipy (#258)
    • Error out on unexpected dims in parameter constraint generation (#270)
    • Compute acquisition values in gen_ functions w/o grad (#274)

    Tests

    • Introduce BotorchTestCase to simplify test code (#243)
    • Refactor tests to have monolithic cuda tests (#261)
    Source code(tar.gz)
    Source code(zip)
  • v0.1.3(Aug 10, 2019)

    Compatibility

    • Updates to support breaking changes in PyTorch to boolean masks and tensor comparisons (#224).
    • Require PyTorch >=1.2 (#225).
    • Require GPyTorch >=0.3.5 (itself a compatibility release).

    New Features

    • Add FixedFeatureAcquisitionFunction wrapper that simplifies optimizing acquisition functions over a subset of input features (#219).
    • Add ScalarizedObjective for scalarizing posteriors (#210).
    • Change default optimization behavior to use L-BFGS-B by for box constraints (#207).

    Bug fixes

    • Add validation to candidate generation (#213), making sure constraints are strictly satisfied (rater than just up to numerical accuracy of the optimizer).

    Minor changes

    • Introduce AcquisitionObjective base class (#220).
    • Add propagate_grads context manager, replacing the propagate_grads kwarg in model posterior() calls (#221)
    • Add batch_initial_conditions argument to joint_optimize() for warm-starting the optimization (ec3365a37ed02319e0d2bb9bea03aee89b7d9caa).
    • Add return_best_only argument to joint_optimize() (#216). Useful for implementing advanced warm-starting procedures.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Jul 10, 2019)

    Bug fixes

    • Avoid PyTorch bug resulting in bad gradients on GPU by requiring GPyTorch >= 0.3.4
    • Fixes to resampling behavior in MCSamplers (#204)

    Experimental Features

    • Linear truncated kernel for multi-fidelity bayesian optimization (#192)
    • SingleTaskMultiFidelityGP for GP models that have fidelity parameters (#181)
    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Jun 28, 2019)

    Breaking changes

    • rename botorch.qmc to botorch.sampling, move MC samplers from acquisition.sampler to botorch.sampling.samplers (#172)

    New Features

    • Add condition_on_observations and fantasize to the Model level API (#173)
    • Support pending observations generically for all MCAcqusitionFunctions (#176)
    • Add fidelity kernel for training iterations/training data points (#178)
    • Support for optimization constraints across q-batches (to support things like sample budget constraints) (2a95a6c3f80e751d5cf8bc7240ca9f5b1529ec5b)
    • Add ModelList <-> Batched Model converter (#187)
    • New test functions
      • basic: neg_ackley, cosine8, neg_levy, neg_rosenbrock, neg_shekel (e26dc7576c7bf5fa2ba4cb8fbcf45849b95d324b)
      • for multi-fidelity BO: neg_aug_branin, neg_aug_hartmann6, neg_aug_rosenbrock (ec4aca744f65ca19847dc368f9fee4cc297533da)

    Improved functionality:

    • More robust model fitting
      • Catch gpytorch numerical issues and return NaN to the optimizer (#184)
      • Restart optimization upon failure by sampling hyperparameters from their prior (#188)
      • Sequentially fit batched and ModelListGP models by default (#189)
      • Change minimum inferred noise level (e2c64fef1e76d526a33951c5eb75ac38d5581257)
    • Introduce optional batch limit in joint_optimize to increases scalability of parallel optimization (baab5786e8eaec02d37a511df04442471c632f8a)
    • Change constructor of ModelListGP to comply with GPyTorchโ€™s IndependentModelList constructor (a6cf739e769c75319a67c7525a023ece8806b15d)
    • Use torch.random to set default seed for samplers (rather than random) to making sampling reproducible when setting torch.manual_seed (ae507ad97255d35f02c878f50ba68a2e27017815)

    Performance Improvements

    • Use einsum in LinearMCObjective (22ca29535717cda0fcf7493a43bdf3dda324c22d)
    • Change default Sobol sample size for MCAquisitionFunctions to be base-2 for better MC integration performance (5d8e81866a23d6bfe4158f8c9b30ea14dd82e032)
    • Add ability to fit models in SumMarginalLogLikelihood sequentially (and make that the default setting) (#183)
    • Do not construct the full covariance matrix when computing posterior of single-output BatchedMultiOutputGPyTorchModel (#185)

    Bug fixes

    • Properly handle observation_noise kwarg for BatchedMultiOutputGPyTorchModels (#182)
    • Fix a issue where f_best was always max for NoisyExpectedImprovement (410de585f07de0c66427d5066947e22227d11537)
    • Fix bug and numerical issues in initialize_q_batch (844dcd1dc8f418ae42639e211c6bb8e31a75d8bf)
    • Fix numerical issues with inv_transform for qMC sampling (#162)

    Other

    • Bump GPyTorch minimum requirement to 0.3.3
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(May 1, 2019)

LBK 14 Mar 11, 2022
Bayesian optimization in PyTorch

BoTorch is a library for Bayesian Optimization built on PyTorch. BoTorch is currently in beta and under active development! Why BoTorch ? BoTorch Prov

null 2.2k Mar 7, 2022
Spearmint Bayesian optimization codebase

Spearmint Spearmint is a software package to perform Bayesian optimization. The Software is designed to automatically run experiments (thus the code n

Formerly: Harvard Intelligent Probabilistic Systems Group -- Now at Princeton 1.5k Mar 7, 2022
Simple, but essential Bayesian optimization package

BayesO: A Bayesian optimization framework in Python Simple, but essential Bayesian optimization package. http://bayeso.org Online documentation Instal

Jungtaek Kim 68 Feb 7, 2022
Safe Bayesian Optimization

SafeOpt - Safe Bayesian Optimization This code implements an adapted version of the safe, Bayesian optimization algorithm, SafeOpt [1], [2]. It also p

Felix Berkenkamp 103 Feb 24, 2022
Bayesian Optimization using GPflow

Note: This package is for use with GPFlow 1. For Bayesian optimization using GPFlow 2 please see Trieste, a joint effort with Secondmind. GPflowOpt GP

GPflow 248 Mar 5, 2022
Information-Theoretic Multi-Objective Bayesian Optimization with Continuous Approximations

Information-Theoretic Multi-Objective Bayesian Optimization with Continuous Approximations Requirements The code is implemented in Python and requires

null 1 Nov 3, 2021
Bayesian Optimization Library for Medical Image Segmentation.

bayesmedaug: Bayesian Optimization Library for Medical Image Segmentation. bayesmedaug optimizes your data augmentation hyperparameters for medical im

ลžafak Bilici 7 Feb 10, 2022
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

้ƒญ้ฃž 3k Mar 5, 2022
library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization

NLopt is a library for nonlinear local and global optimization, for functions with and without gradient information. It is designed as a simple, unifi

Steven G. Johnson 1.2k Mar 1, 2022
Racing line optimization algorithm in python that uses Particle Swarm Optimization.

Racing Line Optimization with PSO This repository contains a racing line optimization algorithm in python that uses Particle Swarm Optimization. Requi

Parsa Dahesh 3 Nov 23, 2021
Python package facilitating the use of Bayesian Deep Learning methods with Variational Inference for PyTorch

PyVarInf PyVarInf provides facilities to easily train your PyTorch neural network models using variational inference. Bayesian Deep Learning with Vari

null 333 Feb 21, 2022
Bayesian Neural Networks in PyTorch

We present the new scheme to compute Monte Carlo estimator in Bayesian VI settings with almost no memory cost in GPU, regardles of the number of sampl

Jurijs Nazarovs 6 Jan 24, 2022
Python Environment for Bayesian Learning

Pebl is a python library and command line application for learning the structure of a Bayesian network given prior knowledge and observations. Pebl in

Abhik Shah 102 Oct 20, 2021
Python Library for learning (Structure and Parameter) and inference (Statistical and Causal) in Bayesian Networks.

pgmpy pgmpy is a python library for working with Probabilistic Graphical Models. Documentation and list of algorithms supported is at our official sit

pgmpy 2k Mar 14, 2022
Python package for Bayesian Machine Learning with scikit-learn API

Python package for Bayesian Machine Learning with scikit-learn API Installing & Upgrading package pip install https://github.com/AmazaspShumik/sklearn

Amazasp Shaumyan 446 Mar 1, 2022
Bayesian dessert for Lasagne

Gelato Bayesian dessert for Lasagne Recent results in Bayesian statistics for constructing robust neural networks have proved that it is one of the be

Maxim Kochurov 84 May 11, 2020
A bare-bones TensorFlow framework for Bayesian deep learning and Gaussian process approximation

Aboleth A bare-bones TensorFlow framework for Bayesian deep learning and Gaussian process approximation [1] with stochastic gradient variational Bayes

Gradient Institute 127 Jan 25, 2022