Reconstruction loss measures how closely a model’s output reproduces its input. In an autoencoder, pixel-wise mean squared error (MSE) provides a simple comparison; a variational autoencoder (VAE) combines this term with Kullback–Leibler divergence to represent distributional learning. section 8.5.2
Common implementation choices include:
- Use MSE for pixel-wise reconstruction comparison. section 8.5.2
- Use binary cross entropy as an alternative reconstruction measure, then compare training behavior after normalizing loss values. section 8.5.2
- Add reconstruction loss to KL loss to form the VAE objective. section 8.5.2
Keras VAE loss
Flatten the input and output tensors, calculate binary cross entropy or MSE, scale the reconstruction term by image size, add KL divergence, and register the mean with add_loss.









