What it is
A variational autoencoder is a generative version of the autoencoder. Instead of mapping an input to a single point, the encoder maps it to a distribution in latent space, which lets you sample new data.
Distributions not points
The encoder outputs a mean and a variance that define a small Gaussian for each input.
- The model samples a latent vector from that Gaussian and decodes it
- To keep gradients flowing through the random sample it uses the reparameterization trick
- The decoder turns the sampled latent vector back into data
The two part loss
Training balances two goals at once.
- A reconstruction term pushes the output to match the input
- A regularization term pulls each encoded distribution toward a standard normal, measured by the Kullback Leibler divergence
This regularizer makes the latent space smooth and continuous, so nearby points decode into similar data. Because of that structure you can sample a random latent vector from a standard normal and generate brand new, plausible examples.
Key idea
A variational autoencoder encodes inputs as distributions and regularizes the latent space so you can sample new data from it.