variational_expectation#

gpjax.objectives.variational_expectation(variational_family, data)[source]#

Compute the variational expectation.

Compute the expectation of our model’s log-likelihood under our variational distribution. Batching can be done here to speed up computation.

Example

>>> import gpjax as gpx
>>> import jax.numpy as jnp
>>> xtrain = jnp.linspace(0, 1).reshape(-1, 1)
>>> ytrain = jnp.sin(xtrain)
>>> D = gpx.Dataset(X=xtrain, y=ytrain)
>>> meanf = gpx.mean_functions.Constant()
>>> kernel = gpx.kernels.RBF()
>>> likelihood = gpx.likelihoods.Bernoulli()
>>> prior = gpx.gps.Prior(mean_function=meanf, kernel=kernel)
>>> posterior = prior * likelihood
>>> z = jnp.linspace(0, 1, 10).reshape(-1, 1)
>>> q = gpx.variational_families.VariationalGaussian(
...     model=posterior, inducing_inputs=z
... )
>>> gpx.objectives.variational_expectation(q, D)
Parameters:
  • variational_family (VF) – The variational family that we are using to approximate the posterior.

  • data (Dataset) – The batch for which the expectation should be computed for.

Returns:

The expectation of the model’s log-likelihood under our variational distribution.

Return type:

Array