Skip to content

Commit fe566d5

Browse files
committed
Modify docstring in advi().
1 parent a53728e commit fe566d5

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

pymc3/variational/advi.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
'''
3-
Created on Mar 12, 2011
3+
Created on 2016
44
55
@author: johnsalvatier
66
'''
@@ -19,7 +19,7 @@
1919
from pymc3.sampling import NDArray
2020
from pymc3.backends.base import MultiTrace
2121

22-
__all__ = ['advi']
22+
__all__ = ['advi', 'sample_vp']
2323

2424
ADVIFit = namedtuple('ADVIFit', 'means, stds, elbo_vals')
2525

@@ -32,7 +32,29 @@ def check_discrete_rvs(vars):
3232

3333
def advi(vars=None, start=None, model=None, n=5000, accurate_elbo=False,
3434
learning_rate=.001, epsilon=.1, random_seed=20090425, verbose=1):
35-
"""Run ADVI.
35+
"""Performe automatic differentiation variational inference (ADVI).
36+
37+
This function implements the meanfield ADVI, where the variational
38+
posterior distribution is assumed to spherical Gaussian without
39+
correlation of parameters and fit to the true posterior distribution.
40+
The means and standard deviations of the variational posterior are referred
41+
to as variational parameters.
42+
43+
The return value of this function is an :code:`ADVIfit` object, which has
44+
variational parameters. If you want to draw samples from the variational
45+
posterior, you need to pass the :code:`ADVIfit` object to
46+
:code:`pymc3.variational.sample_vp()`.
47+
48+
The variational parameters are defined on the transformed space, which is
49+
required to do ADVI on an unconstrained parameter space as described in
50+
[KTR+2016]. The parameters in the :code:`ADVIfit` object are in the
51+
transformed space, while traces returned by :code:`sample_vp()` are in
52+
the original space as obtained by MCMC sampling methods in PyMC3.
53+
54+
The variational parameters are optimized with a modified version of
55+
Adagrad, where only the last (n_window) gradient vectors are used to
56+
control the learning rate and older gradient vectors are ignored.
57+
n_window denotes the size of time window and fixed to 10.
3658
3759
Parameters
3860
----------
@@ -58,9 +80,15 @@ def advi(vars=None, start=None, model=None, n=5000, accurate_elbo=False,
5880
ADVIFit
5981
Named tuple, which includes 'means', 'stds', and 'elbo_vals'.
6082
61-
'means' and 'stds' include parameters of the variational posterior.
62-
"""
83+
'means' is the mean. 'stds' is log of the standard deviation.
84+
'elbo_vals' is the trace of ELBO values during optimizaiton.
6385
86+
References
87+
----------
88+
.. [KTR+2016] Kucukelbir, A., Tran, D., Ranganath, R., Gelman, A.,
89+
and Blei, D. M. (2016). Automatic Differentiation Variational Inference.
90+
arXiv preprint arXiv:1603.00788.
91+
"""
6492
model = modelcontext(model)
6593
if start is None:
6694
start = model.test_point

0 commit comments

Comments
 (0)