trieste.models.gpflow.interface#

Module Contents#

class GPflowPredictor(optimizer: Optimizer | None = None)[source]#

Bases: trieste.models.interfaces.SupportsPredictJoint, trieste.models.interfaces.SupportsGetKernel, trieste.models.interfaces.SupportsGetObservationNoise, trieste.models.interfaces.HasReparamSampler, abc.ABC

A trainable wrapper for a GPflow Gaussian process model.

Parameters

optimizer – The optimizer with which to train the model. Defaults to Optimizer with Scipy.

property optimizertrieste.models.optimizer.Optimizer[source]#

The optimizer with which to train the model.

create_posterior_cache()None[source]#

Create a posterior cache for fast sequential predictions. Note that this must happen at initialisation and after we ensure the model data is variable. Furthermore, the cache must be updated whenever the underlying model is changed.

update_posterior_cache()None[source]#

Update the posterior cache. This needs to be called whenever the underlying model is changed.

property modelgpflow.models.GPModel[source]#

The underlying GPflow model.

predict(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 of query_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.

predict_joint(query_points: trieste.types.TensorType)tuple[trieste.types.TensorType, trieste.types.TensorType][source]#
Parameters

query_points – The points at which to make predictions, of shape […, B, D].

Returns

The mean and covariance of the joint marginal distribution at each batch of points in query_points. For a predictive distribution with event shape E, the mean will have shape […, B] + E, and the covariance shape […] + E + [B, B].

sample(query_points: trieste.types.TensorType, num_samples: int)trieste.types.TensorType[source]#

Return num_samples samples from the independent marginal distributions at query_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.

predict_y(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 for the observations, including noise contributions.

Note that this is not supported by all models.

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.

get_kernel()gpflow.kernels.Kernel[source]#

Return the kernel of the model.

Returns

The kernel.

get_mean_function()gpflow.mean_functions.MeanFunction[source]#

Return the mean function of the model.

Returns

The mean function.

get_observation_noise()trieste.types.TensorType[source]#

Return the variance of observation noise for homoscedastic likelihoods.

Returns

The observation noise.

Raises

NotImplementedError – If the model does not have a homoscedastic likelihood.

optimize(dataset: trieste.data.Dataset)None[source]#

Optimize the model with the specified dataset.

Parameters

dataset – The data with which to optimize the model.

log(dataset: Optional[trieste.data.Dataset] = None)None[source]#

Log model training information at a given optimization step to the Tensorboard. We log kernel and likelihood parameters. We also log several training data based metrics, such as root mean square error between predictions and observations and several others.

Parameters

dataset – Optional data that can be used to log additional data-based model summaries.

reparam_sampler(num_samples: int)trieste.models.interfaces.ReparametrizationSampler[GPflowPredictor][source]#

Return a reparametrization sampler providing num_samples samples.

Returns

The reparametrization sampler.

class SupportsCovarianceBetweenPoints[source]#

Bases: trieste.models.interfaces.SupportsPredictJoint, typing_extensions.Protocol

A probabilistic model that supports covariance_between_points.

abstract covariance_between_points(query_points_1: trieste.types.TensorType, query_points_2: trieste.types.TensorType)trieste.types.TensorType[source]#

Compute the posterior covariance between sets of query points.

\[\Sigma_{12} = K_{12} - K_{x1}(K_{xx} + \sigma^2 I)^{-1}K_{x2}\]

Note that query_points_2 must be a rank 2 tensor, but query_points_1 can have leading dimensions.

Parameters
  • query_points_1 – Set of query points with shape […, N, D]

  • query_points_2 – Sets of query points with shape [M, D]

Returns

Covariance matrix between the sets of query points with shape […, L, N, M] (L being the number of latent GPs = number of output dimensions)