tfp.experimental.bayesopt.acquisition.ParallelUpperConfidenceBound
Stay organized with collections
Save and categorize content based on your preferences.
Parallel upper confidence bound acquisition function.
Inherits From: AcquisitionFunction
tfp.experimental.bayesopt.acquisition.ParallelUpperConfidenceBound(
predictive_distribution,
observations,
seed=None,
exploration=0.01,
num_samples=100,
transform_fn=None
)
Computes the q-UCB based on observed data using a stochastic process surrogate
model. The computation is of the form mean + exploration * stddev
.
Requires that predictive_distribution
has a sample
method.
Examples
Build and evaluate a Parallel Upper Confidence Bound acquisition function.
import numpy as np
import tensorflow_probability as tfp
tfd = tfp.distributions
tfpk = tfp.math.psd_kernels
tfp_acq = tfp.experimental.bayesopt.acquisition
# Sample 10 20-dimensional index points and associated observations.
index_points = np.random.uniform(size=[10, 20])
observations = np.random.uniform(size=[10])
# Build a GP regression model conditioned on observed data.
dist = tfd.GaussianProcessRegressionModel(
kernel=tfpk.ExponentiatedQuadratic(),
observation_index_points=index_points,
observations=observations)
gp_pucb = tfp_acq.ParallelUpperConfidenceBound(
predictive_distribution=dist,
observations=observations,
exploration=0.05,
num_samples=int(2e4))
# Evaluate the acquisition function at a set of predictive index points.
pred_index_points = np.random.uniform(size=[6, 20])
acq_fn_vals = gp_pucb(pred_index_points) # Has shape [6].
Args |
predictive_distribution
|
tfd.Distribution -like, the distribution over
observations at a set of index points. Must have a sample method.
|
observations
|
Float Tensor of observations. Shape has the form
[b1, ..., bB, e] , where e is the number of index points (such that
the event shape of predictive_distribution is [e] ) and
[b1, ..., bB] is broadcastable with the batch shape of
predictive_distribution .
|
seed
|
PRNG seed; see tfp.random.sanitize_seed for details.
|
exploration
|
Exploitation-exploration trade-off parameter.
|
num_samples
|
The number of samples to use for the Paralle Expected
Improvement approximation.
|
transform_fn
|
Optional Python Callable that transforms objective values.
This is used for optimizing a composite grey box function g(f(x))
where f is our black box function and g is transform_fn .
|
Attributes |
exploration
|
|
is_parallel
|
Python bool indicating whether the acquisition function is parallel.
Parallel (batched) acquisition functions evaluate batches of points rather
than single points.
|
num_samples
|
|
observations
|
Float Tensor of observations.
|
predictive_distribution
|
The distribution over observations at a set of index points.
|
seed
|
PRNG seed.
|
transform_fn
|
|
Methods
__call__
View source
__call__(
**kwargs
)
Computes the Parallel Upper Confidence Bound.
Args |
**kwargs
|
Keyword args passed on to the sample method of
predictive_distribution .
|
Returns |
Parallel upper confidence bounds at index points implied by
predictive_distribution (or overridden in **kwargs ).
|
References
[1] J. Wilson, R. Moriconi, F. Hutter, M. Deisenroth
The reparameterization trick for acquisition functions
https://bayesopt.github.io/papers/2017/32.pdf
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[null,null,["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.experimental.bayesopt.acquisition.ParallelUpperConfidenceBound\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/bayesopt/acquisition/upper_confidence_bound.py#L24-L151) |\n\nParallel upper confidence bound acquisition function.\n\nInherits From: [`AcquisitionFunction`](../../../../tfp/experimental/bayesopt/acquisition/AcquisitionFunction) \n\n tfp.experimental.bayesopt.acquisition.ParallelUpperConfidenceBound(\n predictive_distribution,\n observations,\n seed=None,\n exploration=0.01,\n num_samples=100,\n transform_fn=None\n )\n\nComputes the q-UCB based on observed data using a stochastic process surrogate\nmodel. The computation is of the form `mean + exploration * stddev`.\n\nRequires that `predictive_distribution` has a `sample` method.\n\n#### Examples\n\nBuild and evaluate a Parallel Upper Confidence Bound acquisition function. \n\n import numpy as np\n import tensorflow_probability as tfp\n\n tfd = tfp.distributions\n tfpk = tfp.math.psd_kernels\n tfp_acq = tfp.experimental.bayesopt.acquisition\n\n # Sample 10 20-dimensional index points and associated observations.\n index_points = np.random.uniform(size=[10, 20])\n observations = np.random.uniform(size=[10])\n\n # Build a GP regression model conditioned on observed data.\n dist = tfd.GaussianProcessRegressionModel(\n kernel=tfpk.ExponentiatedQuadratic(),\n observation_index_points=index_points,\n observations=observations)\n\n gp_pucb = tfp_acq.ParallelUpperConfidenceBound(\n predictive_distribution=dist,\n observations=observations,\n exploration=0.05,\n num_samples=int(2e4))\n\n # Evaluate the acquisition function at a set of predictive index points.\n pred_index_points = np.random.uniform(size=[6, 20])\n acq_fn_vals = gp_pucb(pred_index_points) # Has shape [6].\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `predictive_distribution` | `tfd.Distribution`-like, the distribution over observations at a set of index points. Must have a `sample` method. |\n| `observations` | `Float` `Tensor` of observations. Shape has the form `[b1, ..., bB, e]`, where `e` is the number of index points (such that the event shape of `predictive_distribution` is `[e]`) and `[b1, ..., bB]` is broadcastable with the batch shape of `predictive_distribution`. |\n| `seed` | PRNG seed; see tfp.random.sanitize_seed for details. |\n| `exploration` | Exploitation-exploration trade-off parameter. |\n| `num_samples` | The number of samples to use for the Paralle Expected Improvement approximation. |\n| `transform_fn` | Optional Python `Callable` that transforms objective values. This is used for optimizing a composite grey box function `g(f(x))` where `f` is our black box function and `g` is `transform_fn`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `exploration` | \u003cbr /\u003e \u003cbr /\u003e |\n| `is_parallel` | Python `bool` indicating whether the acquisition function is parallel. \u003cbr /\u003e Parallel (batched) acquisition functions evaluate batches of points rather than single points. |\n| `num_samples` | \u003cbr /\u003e \u003cbr /\u003e |\n| `observations` | Float `Tensor` of observations. |\n| `predictive_distribution` | The distribution over observations at a set of index points. |\n| `seed` | PRNG seed. |\n| `transform_fn` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/bayesopt/acquisition/upper_confidence_bound.py#L117-L151) \n\n __call__(\n **kwargs\n )\n\nComputes the Parallel Upper Confidence Bound.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|------------|-----------------------------------------------------------------------------|\n| `**kwargs` | Keyword args passed on to the `sample` method of `predictive_distribution`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| Parallel upper confidence bounds at index points implied by `predictive_distribution` (or overridden in `**kwargs`). ||\n\n\u003cbr /\u003e\n\n#### References\n\n\\[1\\] J. Wilson, R. Moriconi, F. Hutter, M. Deisenroth\nThe reparameterization trick for acquisition functions\n\u003chttps://bayesopt.github.io/papers/2017/32.pdf\u003e"]]