VAE: can't reconstruct input images using MSE loss

I have implemented a VAE in Pytorch with MNIST database.
I noticed that when I use the F.mse_loss, I don’t get a good reconstruction of the input images.
Here is an exmaple of the reconstruction of some input images:

But when I use the F.binary_cross_entropy loss, I get a good reconstruction:reconstruction_9
Can you please help me understand why I can’t get a good reconstruction of the input images when using the mse loss?
I appreciate your help!

Based on Chapter 6.2.2, DeepLearningBook, I would assume nn.BCELoss to work better, as you are dealing with a Bernoulli Output Distribution, but I’m no expert on this topic, so let’s wait for others to chime in. :wink:

Thank you. :slightly_smiling_face: