I'm interested in evaluating $p(x)$ using a variational autoencoder. I would expect the straightforward way to estimate the marginal likelihood to be based on importance sampling:

\begin{align} p(x) &= \int_z p(z) p(x|z) \frac{q(z|x)}{q(z|x)} dz \\ & = \mathbb{E}_{q(z|x)} [ p(x | z) \frac{p(z)}{q(z|x)} ] \end{align}


  1. in Kingma and Welling (2013), the authors suggest a different method in appendix D. Is there a good reason for this?

  2. The authors furthermore suggest to estimate $q(z|x)$ with a density estimation after drawing samples from it. Why is this necessary if we know $q(z|x)$ explicitly?

  • 1
    $\begingroup$ Why should the estimator be based on importance sampling, though? $\endgroup$ Apr 16 at 13:39
  • $\begingroup$ @Xi'an apologies, I added the reference $\endgroup$
    – Lisa
    Apr 16 at 14:27
  • 1
    $\begingroup$ @AryaMcCarthy I'm still working on my understanding there, but it seemed intuitive given that the ELBO can be obtained directly through importance sampling. Can you explain the what might speak for or against the different estimators? $\endgroup$
    – Lisa
    Apr 16 at 14:34
  • 1
    $\begingroup$ Importance sampling can give poor estimates—there may be high variability in the importance weights; samples from $q_\phi$ may not fully cover $p_\theta$. They used Hamiltonian Monte Carlo to draw samples from the true posterior instead of the approximate one. From there, it looks like they used a tweaked version of the harmonic mean estimator that gets constantly criticized for working poorly, but keeps getting used because it's easy to code. Dunno whether using $q$ improved it. $\endgroup$ Apr 17 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.