botorch.posteriors
Posterior APIs
Abstract Posterior API
Abstract base module for all botorch posteriors.
- class botorch.posteriors.posterior.Posterior[source]
Bases:
ABCAbstract base class for botorch posteriors.
- rsample_from_base_samples(sample_shape, base_samples)[source]
Sample from the posterior (with gradients) using base samples.
This is intended to be used with a sampler that produces the corresponding base samples, and enables acquisition optimization via Sample Average Approximation.
- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor) – The base samples, obtained from the appropriate sampler. This is a tensor of shape
sample_shape x base_sample_shape.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- abstractmethod rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- sample(sample_shape=None)[source]
Sample from the posterior without gradients.
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- abstract property device: device
The torch device of the distribution.
- abstract property dtype: dtype
The torch dtype of the distribution.
- quantile(value)[source]
Compute quantiles of the distribution.
For multi-variate distributions, this may return the quantiles of the marginal distributions.
- Parameters:
value (Tensor)
- Return type:
Tensor
- density(value)[source]
The probability density (or mass) of the distribution.
For multi-variate distributions, this may return the density of the marginal distributions.
- Parameters:
value (Tensor)
- Return type:
Tensor
- property base_sample_shape: Size
The base shape of the base samples expected in
rsample.Informs the sampler to produce base samples of shape
sample_shape x base_sample_shape.
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.
Posterior List API
A Posterior represented by a list of independent Posteriors.
- class botorch.posteriors.posterior_list.PosteriorList(*posteriors)[source]
Bases:
PosteriorA Posterior represented by a list of independent Posteriors.
When at least one of the posteriors is a
GaussianMixturePosterior, the other posteriors are expanded to match the size of theGaussianMixturePosterior.A Posterior represented by a list of independent Posteriors.
- Parameters:
*posteriors (Posterior) – A variable number of single-outcome posteriors.
Example
>>> p_1 = model_1.posterior(test_X) >>> p_2 = model_2.posterior(test_X) >>> p_12 = PosteriorList(p_1, p_2)
Note: This is typically produced automatically in
ModelList; it should generally not be necessary for the end user to invoke it manually.- property device: device
The torch device of the posterior.
- property dtype: dtype
The torch dtype of the posterior.
- property mean: Tensor
The mean of the posterior as a
(b) x n x m-dim Tensor.This is only supported if all posteriors provide a mean.
- property variance: Tensor
The variance of the posterior as a
(b) x n x m-dim Tensor.This is only supported if all posteriors provide a variance.
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
Posteriors
Torch Posterior
Posterior module to be used with PyTorch distributions.
- class botorch.posteriors.torch.TorchPosterior(distribution)[source]
Bases:
PosteriorA posterior based on a PyTorch Distribution.
NOTE: For any attribute that is not explicitly defined on the Posterior level, this returns the corresponding attribute of the distribution. This allows easy access to the distribution attributes, without having to expose them on the Posterior.
A posterior based on a PyTorch Distribution.
- Parameters:
distribution (Distribution) – A PyTorch Distribution object.
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
This is generally used with a sampler that produces the base samples.
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- property device: device
The torch device of the distribution.
- property dtype: dtype
The torch dtype of the distribution.
GPyTorch Posterior
Posterior module to be used with GPyTorch models.
- class botorch.posteriors.gpytorch.GPyTorchPosterior(distribution)[source]
Bases:
TorchPosteriorA posterior based on GPyTorch’s multi-variate Normal distributions.
A posterior based on GPyTorch’s multi-variate Normal distributions.
- Parameters:
distribution (MultivariateNormal) – A GPyTorch MultivariateNormal (single-output case) or MultitaskMultivariateNormal (multi-output case).
- distribution: MultivariateNormal
- property mvn: MultivariateNormal
Expose the distribution as a backwards-compatible attribute.
- property base_sample_shape: Size
The shape of a base sample used for constructing posterior samples.
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.
- rsample_from_base_samples(sample_shape, base_samples)[source]
Sample from the posterior (with gradients) using base samples.
This is intended to be used with a sampler that produces the corresponding base samples, and enables acquisition optimization via Sample Average Approximation.
- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor) – A Tensor of
N(0, I)base samples of shapesample_shape x base_sample_shape, typically obtained from aSampler. This is used for deterministic optimization.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- property mean: Tensor
The posterior mean.
- property variance: Tensor
The posterior variance.
- botorch.posteriors.gpytorch.scalarize_posterior_gpytorch(posterior, weights, offset=0.0)[source]
Helper function for
scalarize_posterior, producing a mean and variance.This mean and variance are consumed by
scalarize_posteriorto produce aGPyTorchPosterior.- Parameters:
posterior (GPyTorchPosterior) – The posterior over
moutcomes to be scalarized. Supportst-batching.weights (Tensor) – A tensor of weights of size
m.offset (float) – The offset of the affine transformation.
- Returns:
- The transformed (single-output) posterior. If the input posterior has
mean
muand covariance matrixSigma, this posterior has meanweights^T * muand varianceweights^T Sigma w.
- Return type:
tuple[Tensor, Tensor | LinearOperator]
Example
Example for a model with two outcomes:
>>> X = torch.rand(1, 2) >>> posterior = model.posterior(X) >>> weights = torch.tensor([0.5, 0.25]) >>> mean, cov = scalarize_posterior_gpytorch(posterior, weights=weights) >>> mvn = MultivariateNormal(mean, cov) >>> new_posterior = GPyTorchPosterior
- botorch.posteriors.gpytorch.scalarize_posterior(posterior, weights, offset=0.0)[source]
Affine transformation of a multi-output posterior.
- Parameters:
posterior (GPyTorchPosterior | PosteriorList) – The posterior over
moutcomes to be scalarized. Supportst-batching. Can be either aGPyTorchPosterior, or aPosteriorListthat contains GPyTorchPosteriors all with q=1.weights (Tensor) – A tensor of weights of size
m.offset (float) – The offset of the affine transformation.
- Returns:
- The transformed (single-output) posterior. If the input posterior has
mean
muand covariance matrixSigma, this posterior has meanweights^T * muand varianceweights^T Sigma w.
- Return type:
Example
Example for a model with two outcomes:
>>> X = torch.rand(1, 2) >>> posterior = model.posterior(X) >>> weights = torch.tensor([0.5, 0.25]) >>> new_posterior = scalarize_posterior(posterior, weights=weights)
Ensemble Posterior
Ensemble posteriors. Used in conjunction with ensemble models.
- class botorch.posteriors.ensemble.EnsemblePosterior(values, weights=None)[source]
Bases:
PosteriorEnsemble posterior, that should be used for ensemble models that compute eagerly a finite number of samples per X value as for example a deep ensemble or a random forest.
- Parameters:
values (Tensor) – Values of the samples produced by this posterior as a
(b) x s x q x mtensor wheremis the output size of the model andsis the ensemble size.weights (Tensor | None) – Optional weights for the ensemble members as a tensor of shape
(s,). If None, uses uniform weights.
- property ensemble_size: int
The size of the ensemble
- property mixture_size: int
The total number of elements in the mixture dimensions
- property weights: Tensor
The weights of the individual models in the ensemble. uniformly weighted by default.
- property mixture_weights: Tensor
The weights of the individual models in the ensemble. uniformly weighted by default, and normalized over ensemble and batch dimensions of the model.
- property mixture_dims: list[int]
The mixture dimensions of the posterior. For ensemble posteriors, this includes all dimensions except the last two (query points and outputs).
- property device: device
The torch device of the posterior.
- property dtype: dtype
The torch dtype of the posterior.
- property mean: Tensor
The mean of the posterior as a
(b) x n x m-dim Tensor.
- property variance: Tensor
The variance of the posterior as a
(b) x n x m-dim Tensor.Computed as the weighted sample variance across the ensemble outputs.
This treats weights as probability weights (normalized to sum to 1) and computes the unbiased weighted sample variance using the formula: Var = Σ(w_i * (x_i - μ)²) / (1 - Σw_i²) where the sum over w_i² is taken over the ensemble dimension only. Source: https://en.wikipedia.org/wiki/Weighted_arithmetic_mean under “Reliability Weights”.
- property mixture_mean: Tensor
The mixture mean of the posterior as a
(b) x n x m-dim Tensor.Computed as the weighted average across the ensemble outputs.
- property mixture_variance: Tensor
The mixture variance of the posterior as a
(b) x n x m-dim Tensor.Computed as the weighted sample variance across the ensemble outputs.
This treats weights as probability weights (normalized to sum to 1) and computes the unbiased weighted sample variance using the formula: Var = Σ(w_i * (x_i - μ)²) / (1 - Σw_i²) where w_i is normalized over the entire mixture, and the sum over w_i² is taken over all mixture dimensions. Source: https://en.wikipedia.org/wiki/Weighted_arithmetic_mean under “Reliability Weights”.
- property batch_shape: Size
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
Based on the sample shape, base samples are generated and passed to
rsample_from_base_samples.- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- rsample_from_base_samples(sample_shape, base_samples)[source]
Sample from the posterior (with gradients) using base samples.
This is intended to be used with a sampler that produces the corresponding base samples, and enables acquisition optimization via Sample Average Approximation.
- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor) – A Tensor of indices as base samples of shape
sample_shape, typically obtained fromIndexSampler. This is used for deterministic optimization. The predictions of the ensemble corresponding to the indices are then sampled.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
Higher Order GP Posterior
- class botorch.posteriors.higher_order.HigherOrderGPPosterior(distribution, joint_covariance_matrix, train_train_covar, test_train_covar, train_targets, output_shape, num_outputs)[source]
Bases:
GPyTorchPosteriorPosterior class for a Higher order Gaussian process model [Zhe2019hogp]. Extends the standard GPyTorch posterior class by overwriting the rsample method. The posterior variance is handled internally by the HigherOrderGP model. HOGP is a tensorized GP model so the posterior covariance grows to be extremely large, but is highly structured, which means that we can exploit Kronecker identities to sample from the posterior using Matheron’s rule as described in [Doucet2010sampl].
In general, this posterior should ONLY be used for HOGP models that have highly structured covariances. It should also only be used internally when called from the HigherOrderGP.posterior(…) method. At this time, the posterior does not support gradients with respect to the training data.
A Posterior for HigherOrderGP models.
- Parameters:
distribution (MultivariateNormal) – Posterior multivariate normal distribution.
joint_covariance_matrix (LinearOperator) – Joint test train covariance matrix over the entire tensor.
train_train_covar (LinearOperator) – Covariance matrix of train points in the data space.
test_train_covar (LinearOperator) – Covariance matrix of test x train points in the data space.
train_targets (Tensor) – Training responses vectorized.
output_shape (Size) – Shape output training responses.
num_outputs (int) – Batch shaping of model.
- property base_sample_shape
The shape of a base sample used for constructing posterior samples.
Overwrites the standard
base_sample_shapecall to inform samplers thatn + 2 n_trainsamples need to be drawn rather than n samples.
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.
- rsample_from_base_samples(sample_shape, base_samples)[source]
Sample from the posterior (with gradients) using base samples.
As the posterior covariance is difficult to draw from in this model, we implement Matheron’s rule as described in [Doucet2010sampl]-. This may not work entirely correctly for deterministic base samples unless base samples are provided that are of shape
n + 2 * n_trainbecause the sampling method draws2 * n_trainsamples as well as the standardn. samples.- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor | None) – An (optional) Tensor of
N(0, I)base samples of appropriate dimension, typically obtained from aSampler. This is used for deterministic optimization.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
Latent Kronecker GP Posterior
- class botorch.posteriors.latent_kronecker.LatentKroneckerGPPosterior(model, distribution, X, T)[source]
Bases:
GPyTorchPosteriorPosterior class for a LatentKroneckerGP model.
Uses a real MultivariateNormal distribution for
.meanand.variance, while internally using pathwise conditioning (Matheron’s rule) for efficient sampling viarsample[wilson2020sampling, wilson2021pathwise].This enables accessing
posterior.meanandposterior.variancewhile maintaining efficient sampling throughmodel._rsample_from_base_samples().Initialize LatentKroneckerGPPosterior.
- Parameters:
model (GPyTorchModel) – The LatentKroneckerGP model to which this posterior belongs to.
distribution (MultivariateNormal) – The posterior MultivariateNormal distribution computed via the GPyTorch prediction stack.
X (Tensor) – A
(batch_shape) x q x d-dim Tensor, wheredis the dimension of the feature space andqis the number of points considered jointly, on which the posterior shall be evaluated.T (Tensor) – A
(batch_shape) x t x 1-dim Tensor ofT-locations at which to evaluate the posterior.
- property base_sample_shape
The shape of a base sample used for constructing posterior samples.
Overwrites the standard
base_sample_shapecall to inform samplers thatn_train_full + n_train + n_testsamples are needed rather than n samples.
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.
- rsample_from_base_samples(sample_shape, base_samples)[source]
Sample from the posterior (with gradients) using base samples.
This is intended to be used with a sampler that produces the corresponding base samples, and enables acquisition optimization via Sample Average Approximation.
Delegates to the model’s pathwise conditioning implementation.
- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor) – A Tensor of
N(0, I)base samples of shapesample_shape x base_sample_shape, typically obtained from aSampler. This is used for deterministic optimization.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
Multitask GP Posterior
- class botorch.posteriors.multitask.MultitaskGPPosterior(distribution, joint_covariance_matrix, test_train_covar, train_diff, test_mean, train_train_covar, train_noise, test_noise=None)[source]
Bases:
GPyTorchPosteriorPosterior class for a Kronecker Multi-task GP model using with ICM kernel. Extends the standard GPyTorch posterior class by overwriting the rsample method. In general, this posterior should ONLY be used for MTGP models that have structured covariances. It should also only be used internally when called from the
KroneckerMultiTaskGP.posterior(...)method.- Parameters:
distribution (MultivariateNormal) – Posterior multivariate normal distribution.
joint_covariance_matrix (LinearOperator) – Joint test train covariance matrix over the entire tensor.
test_train_covar (LinearOperator) – Covariance matrix of test x train points in the data space.
train_diff (Tensor) – Difference between train mean and train responses.
test_mean (Tensor) – Test mean response.
train_train_covar (LinearOperator) – Covariance matrix of train points in the data space.
train_noise (LinearOperator | Tensor) – Training noise covariance.
test_noise (LinearOperator | Tensor | None) – Only used if posterior should contain observation noise. Testing noise covariance.
- property base_sample_shape: Size
The shape of a base sample used for constructing posterior samples.
Overwrites the standard
base_sample_shapecall to inform samplers thatn + 2 n_trainsamples need to be drawn rather than n samples.
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.
- rsample_from_base_samples(sample_shape, base_samples, train_diff=None)[source]
Sample from the posterior (with gradients) using base samples.
- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor | None) – An (optional) Tensor of
N(0, I)base samples of appropriate dimension, typically obtained from aSampler. This is used for deterministic optimization.train_diff (Tensor | None) – Difference between train mean and train responses to assume during sampling.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
Transformed Posterior
- class botorch.posteriors.transformed.TransformedPosterior(posterior, sample_transform, mean_transform=None, variance_transform=None)[source]
Bases:
PosteriorA generic transformation of a posterior (implicitly represented).
An implicitly represented transformed posterior.
- Parameters:
posterior (Posterior) – The posterior object to be transformed.
sample_transform (Callable[[Tensor], Tensor]) – A callable applying a sample-level transform to a
sample_shape x batch_shape x q x m-dim tensor of samples from the original posterior, returning a tensor of samples of the same shape.mean_transform (Callable[[Tensor, Tensor], Tensor] | None) – A callable transforming a 2-tuple of mean and variance (both of shape
batch_shape x m x o) of the original posterior to the mean of the transformed posterior.variance_transform (Callable[[Tensor, Tensor], Tensor] | None) – A callable transforming a 2-tuple of mean and variance (both of shape
batch_shape x m x o) of the original posterior to a variance of the transformed posterior.
- property base_sample_shape: Size
The shape of a base sample used for constructing posterior samples.
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.
- property device: device
The torch device of the posterior.
- property dtype: dtype
The torch dtype of the posterior.
- property mean: Tensor
The mean of the posterior as a
batch_shape x n x m-dim Tensor.
- property variance: Tensor
The variance of the posterior as a
batch_shape x n x m-dim Tensor.
- rsample_from_base_samples(sample_shape, base_samples)[source]
Sample from the posterior (with gradients) using base samples.
This is intended to be used with a sampler that produces the corresponding base samples, and enables acquisition optimization via Sample Average Approximation.
- Parameters:
sample_shape (Size) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).base_samples (Tensor) – The base samples, obtained from the appropriate sampler. This is a tensor of shape
sample_shape x base_sample_shape.
- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
- rsample(sample_shape=None)[source]
Sample from the posterior (with gradients).
- Parameters:
sample_shape (Size | None) – A
torch.Sizeobject specifying the sample shape. To drawnsamples, set totorch.Size([n]). To drawbbatches ofnsamples each, set totorch.Size([b, n]).- Returns:
Samples from the posterior, a tensor of shape
self._extended_shape(sample_shape=sample_shape).- Return type:
Tensor
Fully Bayesian Posterior
- botorch.posteriors.fully_bayesian.batched_bisect(f, target, bounds, tol=1e-06, max_steps=32)[source]
Batched bisection with a fixed number of steps.
- Parameters:
f (Callable) – Target function that takes a
(b1 x ... x bk)-dim tensor and returns a(b1 x ... x bk)-dim tensor.target (float) – Scalar target value of type float.
bounds (Tensor) – Lower and upper bounds, of size
2 x b1 x ... x bk.tol (float) – We terminate if all elements are within
tolof thetarget.max_steps (int) – Maximum number of bisection steps.
- Returns:
Tensor X of size
b1 x ... x bksuch thatf(X) = target.
- class botorch.posteriors.fully_bayesian.GaussianMixturePosterior(distribution)[source]
Bases:
GPyTorchPosteriorA Gaussian mixture posterior.
The MCMC batch dimension that corresponds to the models in the mixture is located at
MCMC_DIM(defined at the top of this file). Note that while each MCMC sample corresponds to a Gaussian posterior, the posterior is rather a mixture of Gaussian distributions.A posterior for a fully Bayesian model.
- Parameters:
distribution (MultivariateNormal) – A GPyTorch MultivariateNormal (single-output case)
- property mixture_mean: Tensor
The posterior mean for the mixture of models.
- property mixture_variance: Tensor
The posterior variance for the mixture of models.
- property mixture_covariance_matrix: Tensor
The posterior covariance matrix for the mixture of models.
- quantile(value)[source]
Compute the posterior quantiles for the mixture of models.
- Parameters:
value (Tensor)
- Return type:
Tensor
- property batch_range: tuple[int, int]
The t-batch range.
This is used in samplers to identify the t-batch component of the
base_sample_shape. The base samples are expanded over the t-batches to provide consistency in the acquisition values, i.e., to ensure that a candidate produces same value regardless of its position on the t-batch.