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.