viabel.bbvi

viabel.bbvi(dimension, *, n_iters=10000, num_mc_samples=10, log_density=None, approx=None, objective=None, fit=None, adaptive=True, fixed_lr=False, init_var_param=None, learning_rate=0.01, RMS_kwargs={}, FASO_kwargs={}, RAABBVI_kwargs={})[source]

Fit a model using black-box variational inference.

Currently the objective is optimized using viabel.optimization.FASO.

Parameters:
dimensionint

Dimension of the model parameter.

n_itersint, optional

Number of iterations of the optimization.

num_mc_samplesint, optional

Number of Monte Carlo samples to use for estimating the gradient of the objective.

log_densityfunction, optional

(Unnormalized) log density of the model. Must support automatic differentiation with autograd. Either log_density or fit must be provided.

approxApproximationFamily object, optional

The approximation family. The default is to use viabel.approximations.MFGaussian.

objectiveVariationalObjective class

The default is to use viabel.objectives.ExclusiveKL.

fitStanFit4model object, optional

If provided, a StanModel will be used. Both fit and log_density cannot be given.

init_var_param, optional

Initial variational parameter.

adaptivebool, optional

If True, use FASO with RMSProp. Otherwise use RMSProp.

fixed_lrbool, optional

If True, use FASO with RMSProp or RMSProp. Otherwise use RAABBVI.

learning_ratefloat

Tuning parameter that determines the step size.

RMS_kwargsdict, optional

Dictionary of keyword arguments to pass to RMSProp.

FASO_kwargsdict, optional

Dictionary of keyword arguments to pass to FASO.

RAABBVI_kwargsdict, optional

Dictionary of keyword arguments to pass to RAABBVI.

Returns:
resultsdict

Contains the following entries: objective and results from optimizer