Variational Inference

Variational Inference

Variational inference involves optimizing the parameters of a variational family to maximize a lower bound on the marginal likelihood called the ELBO. In Gen, variational families are represented as generative functions, and variational inference typically involves optimizing the trainable parameters of generative functions.

Black box variational inference

There are two procedures in the inference library for performing black box variational inference.

``````(elbo_estimate, traces, elbo_history) = black_box_vi!(
model::GenerativeFunction, args::Tuple,
observations::ChoiceMap,
var_model::GenerativeFunction, var_model_args::Tuple,
update::ParamUpdate;
iters=1000, samples_per_iter=100, verbose=false)``````

Fit the parameters of a generative function (`var_model`) to the posterior distribution implied by the given model and observations using stochastic gradient methods.

source
``````(iwelbo_estimate, traces, iwelbo_history) = black_box_vimco!(
model::GenerativeFunction, args::Tuple,
observations::ChoiceMap,
var_model::GenerativeFunction, var_model_args::Tuple,
update::ParamUpdate, num_samples::Int;
iters=1000, samples_per_iter=100, verbose=false)``````

Fit the parameters of a generative function (`var_model`) to the posterior distribution implied by the given model and observations using stochastic gradient methods applied to the Variational Inference with Monte Carlo Objectives lower bound on the marginal likelihood.

source

Reparametrization trick

To use the reparametrization trick to reduce the variance of gradient estimators, users currently need to write two versions of their variational family, one that is reparametrized and one that is not. Gen does not currently include inference library support for this. We plan add add automated support for reparametrization and other variance reduction techniques in the future.