Variational Autoencoders
A variational autoencoder (VAE) is a latent-variable generative model. It specifies a prior and a decoder likelihood :
The true posterior is usually difficult to compute. An encoder amortizes an approximate posterior across observations.
Evidence Lower Bound
Training maximizes the evidence lower bound (ELBO):
It is a lower bound because
The first term rewards a decoder likelihood that explains the observation. The second keeps the approximate posterior near the prior so latent samples can support generation. Calling the first term merely “reconstruction loss” can hide an important modeling choice: Bernoulli, Gaussian, categorical, and other likelihoods imply different objectives and data assumptions.
Reparameterized Gradients
For a diagonal Gaussian encoder,
sample through parameter-free noise:
This moves randomness outside the differentiable path through and .
For a standard normal prior, the KL term has a closed form:
Generation and Variants
- Generation: sample , then sample or decode .
- Conditional VAE: condition the encoder and decoder on additional information .
- -VAE: weight the KL term by to alter the rate–distortion trade-off. A larger weight does not guarantee a uniquely disentangled or semantically meaningful representation.
Failure Modes
- Posterior collapse: a strong decoder may ignore , leaving close to the prior.
- Approximation gap: the chosen variational family may poorly represent the true posterior.
- Likelihood mismatch: a convenient decoder distribution can produce undesirable sample or reconstruction behavior.
- Latent interpretation: smooth interpolation does not prove that latent coordinates correspond to independent human concepts.
- Anomaly detection: reconstruction or likelihood scores can fail on unfamiliar data and need task-specific validation.
The canonical source is Auto-Encoding Variational Bayes. Framework training code is intentionally omitted because the model assumptions and ELBO are the durable part.