trieste.acquisition.interface#
This module contains the interfaces relating to acquisition function — functions that estimate the utility of evaluating sets of candidate points.
Module Contents#
- AcquisitionFunction[source]#
Type alias for acquisition functions.
An
AcquisitionFunctionmaps a set of B query points (each of dimension D) to a single value that describes how useful it would be evaluate all these points together (to our goal of optimizing the objective function). Thus, with leading dimensions, anAcquisitionFunctiontakes input shape […, B, D] and returns shape […, 1].Note that
AcquisitionFunction`s which do not support batch optimization still expect inputs with a batch dimension, i.e. an input of shape `[..., 1, D].
- class AcquisitionFunctionClass[source]#
Bases:
abc.ABCAn
AcquisitionFunctionClassis an acquisition function represented using a class rather than as a standalone function. Using a class to represent an acquisition function makes it easier to update it, to avoid having to retrace the function on every call.
- class AcquisitionFunctionBuilder[source]#
Bases:
Generic[trieste.models.interfaces.ProbabilisticModelType],abc.ABCAn
AcquisitionFunctionBuilderbuilds and updates an acquisition function.- abstract prepare_acquisition_function(models: Mapping[trieste.types.Tag, trieste.models.interfaces.ProbabilisticModelType], datasets: Mapping[trieste.types.Tag, trieste.data.Dataset] | None = None) AcquisitionFunction[source]#
Prepare an acquisition function. We assume that this requires at least models, but it may sometimes also need data.
- Parameters:
models – The models for each tag.
datasets – The data from the observer (optional).
- Returns:
An acquisition function.
- update_acquisition_function(function: AcquisitionFunction, models: Mapping[trieste.types.Tag, trieste.models.interfaces.ProbabilisticModelType], datasets: Mapping[trieste.types.Tag, trieste.data.Dataset] | None = None) AcquisitionFunction[source]#
Update an acquisition function. By default this generates a new acquisition function each time. However, if the function is decorated with @tf.function, then you can override this method to update its variables instead and avoid retracing the acquisition function on every optimization loop.
- Parameters:
function – The acquisition function to update.
models – The models for each tag.
datasets – The data from the observer (optional).
- Returns:
The updated acquisition function.
- class SingleModelAcquisitionBuilder[source]#
Bases:
Generic[trieste.models.interfaces.ProbabilisticModelType],abc.ABCConvenience acquisition function builder for an acquisition function (or component of a composite acquisition function) that requires only one model, dataset pair.
- using(tag: trieste.types.Tag) AcquisitionFunctionBuilder[trieste.models.interfaces.ProbabilisticModelType][source]#
- Parameters:
tag – The tag for the model, dataset pair to use to build this acquisition function.
- Returns:
An acquisition function builder that selects the model and dataset specified by
tag, as defined inprepare_acquisition_function().
- abstract prepare_acquisition_function(model: trieste.models.interfaces.ProbabilisticModelType, dataset: trieste.data.Dataset | None = None) AcquisitionFunction[source]#
- Parameters:
model – The model.
dataset – The data to use to build the acquisition function (optional).
- Returns:
An acquisition function.
- update_acquisition_function(function: AcquisitionFunction, model: trieste.models.interfaces.ProbabilisticModelType, dataset: trieste.data.Dataset | None = None) AcquisitionFunction[source]#
- Parameters:
function – The acquisition function to update.
model – The model.
dataset – The data from the observer (optional).
- Returns:
The updated acquisition function.
- class GreedyAcquisitionFunctionBuilder[source]#
Bases:
Generic[trieste.models.interfaces.ProbabilisticModelType],abc.ABCA
GreedyAcquisitionFunctionBuilderbuilds an acquisition function suitable for greedily building batches for batch Bayesian Optimization. AGreedyAcquisitionFunctionBuilderdiffers from anAcquisitionFunctionBuilderby requiring that a set of pending points is passed to the builder. Note that this acquisition function is typically called B times each Bayesian optimization step, when building batches of size B.- abstract prepare_acquisition_function(models: Mapping[trieste.types.Tag, trieste.models.interfaces.ProbabilisticModelType], datasets: Mapping[trieste.types.Tag, trieste.data.Dataset] | None = None, pending_points: trieste.types.TensorType | None = None) AcquisitionFunction[source]#
Generate a new acquisition function. The first time this is called,
pending_pointswill be None. Subsequent calls will be viaupdate_acquisition_functionbelow, unless that has been overridden.- Parameters:
models – The models over each tag.
datasets – The data from the observer (optional).
pending_points – Points already chosen to be in the current batch (of shape [M,D]), where M is the number of pending points and D is the search space dimension.
- Returns:
An acquisition function.
- update_acquisition_function(function: AcquisitionFunction, models: Mapping[trieste.types.Tag, trieste.models.interfaces.ProbabilisticModelType], datasets: Mapping[trieste.types.Tag, trieste.data.Dataset] | None = None, pending_points: trieste.types.TensorType | None = None, new_optimization_step: bool = True) AcquisitionFunction[source]#
Update an acquisition function. By default this generates a new acquisition function each time. However, if the function is decorated with`@tf.function`, then you can override this method to update its variables instead and avoid retracing the acquisition function on every optimization loop.
- Parameters:
function – The acquisition function to update.
models – The models over each tag.
datasets – The data from the observer (optional).
pending_points – Points already chosen to be in the current batch (of shape [M,D]), where M is the number of pending points and D is the search space dimension.
new_optimization_step – Indicates whether this call to update_acquisition_function is to start of a new optimization step, of to continue collecting batch of points for the current step. Defaults to
True.
- Returns:
The updated acquisition function.
- class SingleModelGreedyAcquisitionBuilder[source]#
Bases:
Generic[trieste.models.interfaces.ProbabilisticModelType],abc.ABCConvenience acquisition function builder for a greedy acquisition function (or component of a composite greedy acquisition function) that requires only one model, dataset pair.
- using(tag: trieste.types.Tag) GreedyAcquisitionFunctionBuilder[trieste.models.interfaces.ProbabilisticModelType][source]#
- Parameters:
tag – The tag for the model, dataset pair to use to build this acquisition function.
- Returns:
An acquisition function builder that selects the model and dataset specified by
tag, as defined inprepare_acquisition_function().
- abstract prepare_acquisition_function(model: trieste.models.interfaces.ProbabilisticModelType, dataset: trieste.data.Dataset | None = None, pending_points: trieste.types.TensorType | None = None) AcquisitionFunction[source]#
- Parameters:
model – The model.
dataset – The data from the observer (optional).
pending_points – Points already chosen to be in the current batch (of shape [M,D]), where M is the number of pending points and D is the search space dimension.
- Returns:
An acquisition function.
- update_acquisition_function(function: AcquisitionFunction, model: trieste.models.interfaces.ProbabilisticModelType, dataset: trieste.data.Dataset | None = None, pending_points: trieste.types.TensorType | None = None, new_optimization_step: bool = True) AcquisitionFunction[source]#
- Parameters:
function – The acquisition function to update.
model – The model.
dataset – The data from the observer (optional).
pending_points – Points already chosen to be in the current batch (of shape [M,D]), where M is the number of pending points and D is the search space dimension.
new_optimization_step – Indicates whether this call to update_acquisition_function is to start of a new optimization step, of to continue collecting batch of points for the current step. Defaults to
True.
- Returns:
The updated acquisition function.
- class VectorizedAcquisitionFunctionBuilder[source]#
Bases:
AcquisitionFunctionBuilder[trieste.models.interfaces.ProbabilisticModelType]An
VectorizedAcquisitionFunctionBuilderbuilds and updates a vectorized acquisition function These differ from normal acquisition functions only by their output shape: rather than returning a single value, they return one value per potential query point. Thus, with leading dimensions, they take input shape […, B, D] and returns shape […, B].
- class SingleModelVectorizedAcquisitionBuilder[source]#
Bases:
SingleModelAcquisitionBuilder[trieste.models.interfaces.ProbabilisticModelType]Convenience acquisition function builder for vectorized acquisition functions (or component of a composite vectorized acquisition function) that requires only one model, dataset pair.
- using(tag: trieste.types.Tag) AcquisitionFunctionBuilder[trieste.models.interfaces.ProbabilisticModelType][source]#
- Parameters:
tag – The tag for the model, dataset pair to use to build this acquisition function.
- Returns:
An acquisition function builder that selects the model and dataset specified by
tag, as defined inprepare_acquisition_function().
- PenalizationFunction[source]#
An
PenalizationFunctionmaps a query point (of dimension D) to a single value that described how heavily it should be penalized (a positive quantity). As penalization is applied multiplicatively to acquisition functions, small penalization outputs correspond to a stronger penalization effect. Thus, with leading dimensions, anPenalizationFunctiontakes input shape […, 1, D] and returns shape […, 1].
- class UpdatablePenalizationFunction[source]#
Bases:
abc.ABCAn
UpdatablePenalizationFunctionbuilds and updates a penalization function. Defining a penalization function that can be updated avoids having to retrace on every call.