Variational Inference

Contains the variational inference decorator.

class vanguard.variational.VariationalInference(n_inducing_points=None, n_likelihood_samples=10, variational_strategy_class=None, variational_distribution_class=None, **kwargs)[source]

Set-up a GPController class for variational inference.

This is best used when:

  • the posterior can not be calculated as a closed-form, or

  • there are too many points to train a model in a reasonable time (see [Cheng17]).

Note

This decorator does not take the standard parameters in the Decorator class, as it only affects the input.

Warning

This decorator will force the wrapped controller class to only accept compatible gp_model_class and marginal_log_likelihood_class arguments. The former should be a subclass of vanguard.variational.models.SVGPModel, and the latter must take a num_data int argument (e.g. a subclass of one of the following).

Example:
>>> @VariationalInference(n_inducing_points=100)
... class NewController(GPController):
...     pass
Parameters:
__init__(n_inducing_points=None, n_likelihood_samples=10, variational_strategy_class=None, variational_distribution_class=None, **kwargs)[source]

Initialise self.

Parameters:
  • n_inducing_points (Optional[int]) – The size of the inducing point approximation. Defaults to None, meaning that the number of inducing points will be set to the number of points.

  • n_likelihood_samples (int) – If the marginal likelihood cannot be computed exactly (which is usually the case when using variational inference), it is approximated using MC integration by sampling from the variational posterior and averaging over the likelihood values for each sample. This is the number of samples to use.

  • variational_strategy_class (Optional[type[_VariationalStrategy]]) – The class for the variational strategy to use. Default behaviour is defined in gpytorch.variational.VariationalStrategy ([Hensman15]).

  • variational_distribution_class (Optional[type[_VariationalDistribution]]) – The class for the variational distribution to use. Default behaviour is defined in gpytorch.variational.CholeskyVariationalDistribution (Cholesky).

  • kwargs (Any)

property safe_updates: dict[type, set[str]]

Get a dictionary (class -> set[names]) of overrides/new methods that we consider “safe”.

verify_decorated_class(cls)[source]

Verify that a class can be decorated by this instance.

Parameters:

cls (type[Any]) – The class to be decorated.

Raises:
Return type:

None