Variational autoencoder

Generative · pattern · Image, Noise or seed → Image, Embedding

An autoencoder whose code is a probability distribution, so new samples can be drawn from it.

Also called VAE

Figure 1. The Variational autoencoder as a schematic: the parts it is built from and how data flows between them. Select a part to read about it.

What it does

A VAE’s encoder outputs a mean and a log-variance for each code dimension instead of a single point. A code is sampled as the mean plus the standard deviation times random noise (the reparameterization trick, which keeps sampling differentiable), and the decoder reconstructs the input from it. Training balances reconstruction quality against keeping the code distribution close to a standard normal. After training the encoder can be dropped: sampling a code from the normal distribution and decoding it produces new examples, and moving smoothly through code space morphs between them.

Formula

μ, log σ2 = fenc(x)z = μ + σ ⊙ ε, ε ~ N(0, I)loss = ‖x − fdec(z)‖2 + KL(N(μ, σ2) ‖ N(0, I))

Shapes and parameters

Shapes
Input [N, 784]; μ and log σ² [N, 16]; noise [N, 16]; reconstruction [N, 784].
Parameters
Encoder plus two code heads plus decoder. The example has 200,960 + 2 × 4,112 + 4,352 + 201,488 = 415,024.
Used for
Image and sound generation, latent spaces for diffusion models, learning smooth embeddings.

In WeightSpace

No VAE is in the WeightSpace catalog today; the schematic is here for reference and for the network builder.

Models built as a Variational autoencoder

No model in WeightSpace follows this pattern yet; it is here as a reference.