Weighted acquisition
This module provides most of the functionality we require in NePS for now, i.e., we need the ability to apply an arbitrary weight to an acquisition function.
I spent some time understanding the meaning of the various dimensions of botorch/gpytorch.
The two primary dimensions to consider are:
d- The dimensionality of the design space, i.e. how many hyperparameters.batch- The number of independent evaluations to make, i.e. how many times to evaluate the acquisition function.
There are two extra dimensions which are special cases and need to be accounted for.
-
q- Comes from theqXXXvariants of acquisition, these will add an extra dimensionqto eachbatch, where instead of abatchrepresenting a single config to get the acquisition of, we might instead be getting the acquisition of 5 configs together, representing the joint utility of evaluating these 5 configs, relative to other sets of 5 configs. This dimension is reduced away in the final step of the acquisition when suggesting which set of group of 5 configs to suggest. -
mc_samples- Comes from theSampleReducdingXXXvariants of acquisition, will add an extra dimensionmc_sampleswhich represent the amount of Monte Carlo samples used to estimate the acquisition. These will eventually be reduced away but are present in the intermediate steps. These variants also seem to haveqvariants implicitly and so you are likely to see theqdimension whever you see themc_samplesdimension, even if it is justq=1. -
m- The number of objectives in the multi-objective case. We will specifically ignore this for now, however it exists as the last dimension (afterd) and is the first to be reduced away. They are also used in constrainted settings which we will also ignore for now.
The most expanded tensor shape is the following, with the usual order of reduction being
the following below. If you are not using a SamplingReducing variant, you will not see
mc_samples and if you are not using a q variant, you will not see q. The simplest
case then being acq(tensor: batch x d).
batch x q x d. reduce(..., d) = Config -> Single number (!!!Acq applies here!!!)batch x q. expand(mc_samples , ...) = MC Sampling from posterior (I think)mc_samples x batch x q. reduce(..., q) = Joint-Config-Group -> Single number.mc_samples x batchreduce(mc_samples, ...) = MC-samples -> statistical estimatebatch
Finally we get out a batch of values we can argmax over, used to index into either a
single configuration or a single index into a joint-group of q configurations.
Tip
The mc_samples is not of concern to the WeightedAcquisition below, and
broadcasting can be used, as a result, the apply_weight function only needs
to be able to handle:
- (X: batch x q x d, acq_values: batch x q, acq: A) -> batch x q
If utilizing the configurations X for weighting, you effectively will want
to reduce the d dimension.
As a result of this, acquisition functions need to be able to handle arbitrary dimensions and act accordingly.
This module mostly follows the structure of the
PriorGuidedAcquisitionFunction which weights the acquisition function by a prior.
We use this to create a more generic WeightedAcquisition which follows the required
structure to make new weightings easier to implement, but also to serve as an educational
reference.
WeightedAcquisition
#
Bases: AcquisitionFunction
Class for weighting acquisition functions.
Please see module docstring for more information.
| PARAMETER | DESCRIPTION |
|---|---|
acq
|
The base acquisition function.
TYPE:
|
apply_weight
|
A function that takes the acquisition function values, the design points and the acquisition function itself and returns the weighted acquisition function values. Please see the module docstring for more information on the dimensions and how to handle them. |
Source code in neps/optimizers/acquisition/weighted_acquisition.py
forward
#
Evaluate a weighted acquisition function on the candidate set X.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
A tensor of size
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
A tensor with the |