ExclusiveKL¶
- class viabel.ExclusiveKL(approx, model, num_mc_samples, use_path_deriv=False, hessian_approx_method=None)[source]¶
Exclusive Kullback-Leibler divergence.
Equivalent to using the canonical evidence lower bound (ELBO)
with reparameterized gradient estimator and control variate
This implementation of reparameterization and control variate is based on:
“Reducing Reparameterization Gradient Variance” by Andrew C. Miller, Nicholas J. Foti , Alexander D’Amour , and Ryan P. Adams, Code based on the implementation by Andrew C. Miller: https://github.com/andymiller/ReducedVarianceReparamGradients
- Attributes:
approx
The approximation family.
model
The model.
num_mc_samples
Number of Monte Carlo samples to use to approximate the objective.
Methods
__call__
(var_param)Evaluate objective and its gradient.
update
(var_param, direction)Update the variational parameter in optimization.
- __init__(approx, model, num_mc_samples, use_path_deriv=False, hessian_approx_method=None)[source]¶
- Parameters:
- approxApproximationFamily object
- modelModel object
- num_mc_sampleint
Number of Monte Carlo samples to use to approximate the objective.
- use_path_derivbool
Use path derivative (for “sticking the landing”) gradient estimator
- hessian_approx_method‘string’
- Select from different methods for approximating the hessian:
‘full’ : use the full hessian matrix provided by BridgeStan ‘mean_only’ : use control variate only for mean estimator to avoid calculation of full hessian ‘loo_diag_approx’ : using “leave one out” method with hessian vector product value at other samples to
estimate the diagonal values of hessian
- ‘loo_direct_approx;: the same method as ‘loo_diag_approx’ but use the scaled approximation to the
gradient of scale to do the “loo” estimation