# how to calculate loglikelihood for VAE/VQVAE

I asked this question on /r/MLQuestions aswell.

Although similar questions have been asked a few times here on reddit and elsewhere, I'm still unclear on how one would calculate the log-likelihood of, say, the CIFAR10 test set, under VAE/VQVAE models, as presented in

https://arxiv.org/abs/1711.00937

and related papers. A "black-box" method using tensorflow's tf.distributions (although for binarized MINST) can be found here

https://github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/vae.py

and here

https://github.com/tensorflow/probability/blob/master/tensorflow_probability/examples/vq_vae.py

, but I would love to understand how this value is calculated "manually".

Would anyone care to elaborate on exactly how to estimate this reported value for CIFAR10? I mention this dataset specifically since it's used as benchmark in many recent papers, and since CIFAR10 isn't binary like binarized MNIST.

I'm very thankful for any help! :)

PS: I am aware of a previous explanation on how to convert the log-likelihood value to bits/dim here:

However, Appendix D of the original paper suggests how one might approximately estimate $$p(x)$$ when the latent space is low dimensional.