Solved – why is VAE reconstruction loss equal to MSE loss

autoencodersloss-functionsmsevariational-bayes

At which situations does reconstruction loss of VAE equals MSE loss between input and reconstructed output?

Other answers where not complete!

Best Answer

A VAE models a distribution

$$P(x) = \int P(x|z)P(z) dz$$

When the output is continuous valued, then a common parameterization of $P(x|z)$ is as $$\mathcal{N}(\mu = f(z;\theta), \sigma^2)$$

Recall that a VAE is trained by maximizing the variational lower bound, which can be broken down into two terms:

$$E_{z \sim q}[\log P(x|z)] - \text{KL}(q(z)||p(z))$$

But then the first term is merely the log of the gaussian density, which is (up to some scaling and constants) $(x-\mu)^2$. Hence MSE.