9
$\begingroup$

After doing some research on the topic, I have noticed a surprising deficit of inference packages and libraries that rely on message-passing or optimization methods for Python and R.

To the best of my knowledge, these methods are extremely useful. For example, for a Bayes Network (directed, acyclic) belief-propagation alone should be able to give exact answers. However, most inference software that is available online (e.g. STAN, BUGS, PyMC) rely on MCMC methods.

In the Python case, to the best of my knowledge, neither PyMC, scikit-learn or statsmodels include variational inference algorithms such as belief propagation, message-passing methods or any of their variants.

Why is that? Are these methods less used in practice because they are seen not as powerful or generic as their MCMC counterparts? or Is it simply a matter of lack of manpower and time?

$\endgroup$
6
  • $\begingroup$ Why the close votes? $\endgroup$ Mar 19, 2014 at 21:00
  • $\begingroup$ Likely because your question appears to be about software rather than statistics or machine learning. If you edit to make it very clear which of the CV topics you're asking a question about (i.e. why it's not 'just a software question') the close vote is less likely to succeed (and even if it does succeed, if you edit to so clarify, it is more likely to be reversed by a reopen vote). So if your question clearly looks to be a "belief network" or "variational inference" question (even if it also involves software), it probably should be okay. $\endgroup$
    – Glen_b
    Mar 19, 2014 at 23:36
  • $\begingroup$ Thank you @Glen_b. That makes sense, I understand. I have updated the question. Hopefully that puts it more in the scope of the site. $\endgroup$ Mar 19, 2014 at 23:51
  • 1
    $\begingroup$ That might be sufficient - if I hadn't already voted to keep it open, I would have little concern about doing it now. On the other hand, some people are much more strict about where they draw the line between 'this is a stats/ML question' and 'this is a software question' than I am. You should not take close votes in any way personally, even if it does end up closed or moved to another SE site; this is in part how the site is supposed to work. $\endgroup$
    – Glen_b
    Mar 19, 2014 at 23:53
  • $\begingroup$ This is on topic, hope there'll be a taker at some point. $\endgroup$ Mar 17, 2015 at 18:13

2 Answers 2

2
$\begingroup$

Have you looked at Edward? The Inference API supports among other things Variational inference:

  • Black box variational inference
  • Stochastic variational inference
  • Variational auto-encoders
  • Inclusive KL divergence: KL(p∥q)
$\endgroup$
2
  • $\begingroup$ Thanks! Yes, I actually tested it recently. I think its very new and it wasn't around when I asked the Q. Good to have it in the thread though! $\endgroup$ Aug 30, 2016 at 22:09
  • 2
    $\begingroup$ How did you find working with Edward? As in what did you think? did it satisfy your requirements? $\endgroup$ Aug 31, 2016 at 17:13
4
$\begingroup$

Some years have passed. STAN now implements ADVI (gradients of the ELBO with reparameterization trick), using the vb command (which I guess stands for Variational Bayes). E.g., in R:

library("rstan") # load the rstan library
fit = vb(model, data, output_samples = 20000, adapt_iter = 10000 ,init = list('param1' = param1, ...), seed)

Pyro is a python library that implements BBVI (gradients of the ELBO with log-derivative trick + variance reduction techniques). Main code is:

import pyro
auto_guide = pyro.infer.autoguide.AutoNormal(model)
adam = pyro.optim.Adam({"lr": 0.02})
elbo = pyro.infer.Trace_ELBO()
svi = pyro.infer.SVI(model, auto_guide, adam, elbo)
for step in range(1000): 
    loss = svi.step(data)
$\endgroup$
3
  • 2
    $\begingroup$ Even though it's not hard to google for "stan advi" and find relevant documentation, please make your answer more helpful by providing a bit of information. And perhaps links about the variational inference implemented in stan/pyro. $\endgroup$
    – dipetkov
    Jan 22, 2023 at 17:15
  • $\begingroup$ @dipetkov added some minimal code to show the interface $\endgroup$ Jan 25, 2023 at 20:54
  • $\begingroup$ Thank you for the update. (I've already upvoted.) $\endgroup$
    – dipetkov
    Jan 25, 2023 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.