Variational Autoencoder
An autoencoder whose compressed space is smooth and continuous, so you can sample or walk through it to generate new, realistic data.
Also VAE · latent space
Kingma and Welling, 2013
A map of every possible handwritten digit, where nearby places look alike. Walk slowly from the '1' neighborhood to the '7' neighborhood and you watch one digit morph smoothly into the other.
Where it fits
+All relationships as a list
How it works
A VAE keeps the encoder-decoder shape of an autoencoder but changes what the encoder outputs. Instead of one exact code, it outputs a small cloud: a center and a spread. During training, a random point is drawn from that cloud and decoded.
Two forces shape training:
- Reconstruction: the decoded point should look like the input.
- Regularity: every cloud should stay close to a standard bell curve around the origin.
The second force pushes all the clouds to overlap and fill the space, with no empty gaps. The result is a latent space where every point decodes to something plausible and nearby points decode to similar things. Now you can generate: sample a random point, decode it. Or interpolate: walk in a straight line between two codes and watch one image morph into another.
VAE images are often a bit blurry, and GANs and diffusion models produce sharper results. But VAEs remain important: Stable Diffusion uses an autoencoder of this kind to shrink images before running diffusion.
The math
The VAE maximizes the evidence lower bound (ELBO):
The reparameterization trick writes with , so gradients flow through and .
Everyday use cases
- Case 01
Morphing handwritten digits or faces
Interpolating between two points in the latent space produces a smooth transition.
- Case 02
Inside Stable Diffusion
Stable Diffusion uses a VAE-style autoencoder to compress images into a small latent space where diffusion runs.
Famous examples
Strengths, weaknesses and when to use it
Strengths
- Smooth, meaningful latent space you can sample and interpolate.
- Stable training with a clear objective.
Weaknesses
- Generated images tend to be blurrier than those from GANs or diffusion models.
When to use itWhen you need a well-organized latent space (for interpolation, compression or as the first stage of a latent diffusion model).
Compare with
Check yourself
- Q01
What does a VAE's encoder output, instead of a single code?
Show answer
B: A distribution (mean and variance) over codes
- Q02
Why can you generate new data with a VAE but not reliably with a plain autoencoder?
Show answer
A: The VAE's latent space is pushed to be smooth and filled in, so random points decode to sensible outputs