I am reading the VAEs paper Auto-Encoding Variational Bayes. In their loss function: they define reconstruction loss (second RHS term) as the expected value of the log p(x|z) wrt to the posterior of the prior. I understand that this expectation is the midpoint of the function because the posterior of the prior is a Gaussian. However, how is it possible to directly regress the mean with an MLP? In the encoder an MLP is used to return mean and variance for a Gaussian however in the decoder the MLP directly gives you the sample from p(x|z). Also is there any intuition why with just a sample from p(z) is enough to compute the expectation?
1 Answer
I guess there is a misunderstanding here because the output of the decoder network theoretically also corresponds to the mean parameter of the conditional likelihood $p(x|z)$.
And in fact, in practice, as your title mentions, we directly take this predicted mean as an output sample from the network.
To really get a feel of what is happening, consider the Continuous Bernoulli VAE (article). Here, as opposed to the Gaussian distribution, the parameter $\lambda$ of the CB distribution used as conditional likelihood does not correspond to the mean of the CB distribution, hence the sample is obtained after a further transformation (Equation 8 of the paper).