trieste.models.keras.interface
#
Module Contents#
-
class
KerasPredictor
(optimizer: Optional[trieste.models.optimizer.KerasOptimizer] = None)[source]# Bases:
trieste.models.interfaces.ProbabilisticModel
,abc.ABC
This is an interface for trainable wrappers of TensorFlow and Keras neural network models.
- Parameters
optimizer – The optimizer wrapper containing the optimizer with which to train the model and arguments for the wrapper and the optimizer. The optimizer must be an instance of a
Optimizer
. Defaults toAdam
optimizer with default parameters.- Raises
ValueError – If the optimizer is not an instance of
Optimizer
.
-
property
optimizer
(self) → trieste.models.optimizer.KerasOptimizer[source]# The optimizer wrapper for training the model.
-
predict
(self, query_points: trieste.types.TensorType) → tuple[trieste.types.TensorType, trieste.types.TensorType][source]# Return the mean and variance of the independent marginal distributions at each point in
query_points
.This is essentially a convenience method for
predict_joint()
, where non-event dimensions ofquery_points
are all interpreted as broadcasting dimensions instead of batch dimensions, and the covariance is squeezed to remove redundant nesting.- Parameters
query_points – The points at which to make predictions, of shape […, D].
- Returns
The mean and variance of the independent marginal distributions at each point in
query_points
. For a predictive distribution with event shape E, the mean and variance will both have shape […] + E.
-
abstract
sample
(self, query_points: trieste.types.TensorType, num_samples: int) → trieste.types.TensorType[source]# Return
num_samples
samples from the independent marginal distributions atquery_points
.- Parameters
query_points – The points at which to sample, with shape […, N, D].
num_samples – The number of samples at each point.
- Returns
The samples. For a predictive distribution with event shape E, this has shape […, S, N] + E, where S is the number of samples.
-
class
DeepEnsembleModel
[source]# Bases:
trieste.models.interfaces.ProbabilisticModel
,typing_extensions.Protocol
This is an interface for deep ensemble type of model, primarily for usage by trajectory samplers, to avoid circular imports. These models can act as probabilistic models by deriving estimates of epistemic uncertainty from the diversity of predictions made by individual models in the ensemble.
-
property
ensemble_size
(self) → int[source]# Returns the size of the ensemble, that is, the number of base learners or individual models in the ensemble.
-
abstract
ensemble_distributions
(self, query_points: trieste.types.TensorType) → tuple[tensorflow_probability.distributions.Distribution, Ellipsis][source]# Return distributions for each member of the ensemble. Type of the output will depend on the subclass, it might be a predicted value or a distribution.
- Parameters
query_points – The points at which to return outputs.
- Returns
The outputs for the observations at the specified
query_points
for each member of the ensemble.
-
property