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
GPControllerclass 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
Decoratorclass, as it only affects the input.Warning
This decorator will force the wrapped controller class to only accept compatible
gp_model_classandmarginal_log_likelihood_classarguments. The former should be a subclass ofvanguard.variational.models.SVGPModel, and the latter must take anum_dataintargument (e.g. a subclass of one of the following).- Example:
>>> @VariationalInference(n_inducing_points=100) ... class NewController(GPController): ... pass
- Parameters:
n_likelihood_samples (
int)variational_strategy_class (
Optional[type[_VariationalStrategy]])variational_distribution_class (
Optional[type[_VariationalDistribution]])kwargs (
Any)
- __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 ingpytorch.variational.VariationalStrategy([Hensman15]).variational_distribution_class (
Optional[type[_VariationalDistribution]]) – The class for the variational distribution to use. Default behaviour is defined ingpytorch.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:
- Raises:
TypeError – If cls is not a subclass of the framework_class.
TopmostDecoratorError – If cls is already decorated with a
TopMostDecorator.MissingRequirementsError – If cls is missing a required decorator.
- Return type: