Implementing MC-Based Acquisition function #1692
-
Implementing MC-Based Acquisition functionI try to understand how MC-Based Acquisition functions are implemented. However, I'm unsure how the dimensions in My general setup looks like this: import torch
from botorch.models import SingleTaskGP
from botorch.optim import optimize_acqf
from botorch.acquisition import qExpectedImprovement
from torch.quasirandom import SobolEngine
def func(x):
return 1 + torch.sin(x[..., :1] )
DIM = 1
N_INIT = 2
BATCH_SIZE = 3
X = SobolEngine(dimension=DIM, scramble=True, seed=0).draw(N_INIT)
Y = func(X)
model = SingleTaskGP(X, Y)
acq = qExpectedImprovement(model=model, best_f=Y.min())
candidates_, acq_values = optimize_acqf(
acq,
bounds=torch.cat((-torch.ones(1, DIM), torch.ones(1, DIM))),
q=BATCH_SIZE,
raw_samples=512,
num_restarts=20,
) In the expected improvement acquisition function, I get the shape Judging from the implemented formula, which takes the mean over the first dimension, I assume that the first dimension is "number of samples used to approximate the acquisition functions value". And its value defaults to Is this correct? And can I choose a different value for the number of starting points and for the number of samples? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @qres. You can parse the shape of the posterior samples as For single objective acquisition functions, the default sampler has If you're trying to understand the internals of an acquisition function, I'd recommend manually evaluating the various parts rather than using a utility like
|
Beta Was this translation helpful? Give feedback.
Hi @qres. You can parse the shape of the posterior samples as
sample shape x t-batch shape x q-batch shape x number of outcomes
.For single objective acquisition functions, the default sampler has
sample_shape = torch.Size([512])
.In
optimize_acqf
,raw_samples
candidates (total shape of Xraw_samples x q-batch x dim
, withraw_samples
corresponding to thet-batch shape
) get randomly generated, the acquisition function is evaluated with these, andnum_restarts
candidates are selected from these with Boltzmann sampling. So, that's the512 / 20
dimension you see.The remaining dimensions are simply the
q-batch shape = BATCH_SIZE
and the number of outcomes of the model, which is1
.If you're t…