The max-value entropy search acquisition function
The max value entropy search acquisition function
Max-value entropy search (MES) acquisition function quantifies the information gain about the maximum of a black-box function by observing this black-box function at the candidate set (see [1, 2]). BoTorch provides implementations of the MES acquisition function and its multi-fidelity (MF) version with support for trace observations. In this tutorial, we explain at a high level how the MES acquisition function works, its implementation in BoTorch and how to use the MES acquisition function to query the next point in the optimization process.
In general, we recommend using Ax for a simple BO setup like this one,
since this will simplify your setup (including the amount of code you need to write)
considerably. You can use a custom BoTorch model and acquisition function in Ax,
following the Using BoTorch with Ax
tutorial. To use the MES acquisition function, it is sufficient to add
"botorch_acqf_class": qMaxValueEntropy,
to model_kwargs
. The linked tutorial shows
how to use a custom BoTorch model. If you'd like to let Ax choose which model to use
based on the properties of the search space, you can skip the surrogate
argument in
model_kwargs
.
1. MES acquisition function for with noisy observation
For illustrative purposes, we focus in this section on the non-q-batch-mode case (). We also assume that the evaluation of the black-box function is noisy. Let us first introduce some notation:
- , the maximum of the black-box function in the design space
- , the noisy observation at the design point
- , the differential entropy of random variable with support : the larger is , the larger is the uncertainty of .
- , the value of data set , where denotes the function maximum (a random variable in our context of our model).
The Max-value Entropy Search (MES) acquisition function at after observing can be written as
, which is the mutual information of random variables and . Here follows the max value distribution conditioned on , and follows the GP posterior distribution with noise at after observing .
Rewrite the above formula as
, where are the max value samples drawn from the posterior after observing . Without noise, is a truncated normal distribution with an analytic expression for its entropy. With noise, is not a truncated normal distribution anymore. The question is then how to compute or equivalently ?
Using Bayes' theorem,
, where
- is the posterior probability density function (PDF) with observation noise.
- is the posterior cummulative distribution function (CDF) without observation noise, given any .
We also know from the GP predictive distribution
So
, where
Thus, is the CDF of above Gaussian.
Finally, given , we have
, where is the ratio of two CDFs and is the samples drawn from the posterior distribution with noisy observation. The above formulation for noisy MES is inspired from the MF-MES formulation proposed by Takeno et. al [1], which is essentially the same as what is outlined above.
Putting all together,
The next design point to query is chosen as the point that maximizes this aquisition function, i. e.,
The implementation in Botorch basically follows the above formulation for both non-MF and MF cases. One difference is that, in order to reduce the variance of the MC estimator for , we apply also regression adjustment to get an estimation of ,
, where
This turns out to reduce the variance of the acquisition value by a significant factor, especially when the acquisition value is small, hence making the algorithm numerically more stable.
For the case of , joint optimization becomes difficult, since the q-batch-mode MES acquisiton function becomes not tractable due to the multivariate normal CDF functions in . Instead, the MES acquisition optimization is solved sequentially and using fantasies, i. e., we generate one point each time and when we try to generate the -th point, we condition the models on the points generated prior to this (using the points as fantasies).
References
2. Setting up a toy model
We will fit a standard SingleTaskGP model on noisy observations of the synthetic 2D Branin function on the hypercube .
# Install dependencies if we are running in colab
import sys
if 'google.colab' in sys.modules:
%pip install botorch
import math
import torch
from botorch.test_functions import Branin
from botorch.fit import fit_gpytorch_mll
from botorch.models import SingleTaskGP
from botorch.utils.transforms import standardize, normalize
from gpytorch.mlls import ExactMarginalLogLikelihood
torch.manual_seed(7)
bounds = torch.tensor(Branin._bounds).T
train_X = bounds[0] + (bounds[1] - bounds[0]) * torch.rand(10, 2)
train_Y = Branin(negate=True)(train_X).unsqueeze(-1)
train_X = normalize(train_X, bounds=bounds)
train_Y = standardize(train_Y + 0.05 * torch.randn_like(train_Y))
model = SingleTaskGP(train_X, train_Y)
mll = ExactMarginalLogLikelihood(model.likelihood, model)
fit_gpytorch_mll(mll);
3. Defining the MES acquisition function
The qMaxValueEntropy
acquisition function is a subclass of MCAcquisitionFunction
and
supports pending points X_pending
. Required arguments for the constructor are model
and candidate_set
(the discretized candidate points in the design space that will be
used to draw max value samples). There are also other optional parameters, such as
number of max value samples , number of samples and number
of fantasies (in case of ). Two different sampling algorithms are supported for the
max value samples: the discretized Thompson sampling and the Gumbel sampling introduced
in [2]. Gumbel sampling is the default choice in the acquisition function.
from botorch.acquisition.max_value_entropy_search import qMaxValueEntropy
candidate_set = torch.rand(
1000, bounds.size(1), device=bounds.device, dtype=bounds.dtype
)
candidate_set = bounds[0] + (bounds[1] - bounds[0]) * candidate_set
qMES = qMaxValueEntropy(model, candidate_set)
4. Optimizing the MES acquisition function to get the next candidate points
In order to obtain the next candidate point(s) to query, we need to optimize the
acquisition function over the design space. For case, we can simply call the
optimize_acqf
function in the library. At , due to the intractability of the
aquisition function in this case, we need to use either sequential or cyclic
optimization (multiple cycles of sequential optimization).
from botorch.optim import optimize_acqf
# for q = 1
candidates, acq_value = optimize_acqf(
acq_function=qMES,
bounds=bounds,
q=1,
num_restarts=10,
raw_samples=512,
)
candidates, acq_value
# for q = 2, sequential optimization
candidates_q2, acq_value_q2 = optimize_acqf(
acq_function=qMES,
bounds=bounds,
q=2,
num_restarts=10,
raw_samples=512,
sequential=True,
)
candidates_q2, acq_value_q2
from botorch.optim import optimize_acqf_cyclic
# for q = 2, cyclic optimization
candidates_q2_cyclic, acq_value_q2_cyclic = optimize_acqf_cyclic(
acq_function=qMES,
bounds=bounds,
q=2,
num_restarts=10,
raw_samples=512,
cyclic_options={"maxiter": 2},
)
candidates_q2_cyclic, acq_value_q2_cyclic
The use of the qMultiFidelityMaxValueEntropy
acquisition function is very similar to
qMaxValueEntropy
, but requires additional optional arguments related to the fidelity
and cost models. We will provide more details on the MF-MES acquisition function in a
separate tutorial.