Legacy Concept Lab

Variational Autoencoders & Variational Inference

Stable Diffusion is a latent diffusion model: an autoencoder maps images ↔ compressed latent space where diffusion operates

Concept 7 of 100Generative ModelsPhase 4
#7VAEsGenerative Models
key equation
logpθ(x)Eqϕ[logpθ(xz)]KL(qϕp(z))\log p_\theta(x) \ge \mathbb E_{q_\phi}[\log p_\theta(x\mid z)] - \mathrm{KL}(q_\phi\,\|\,p(z))
Phase 4: Generative modeling familiesConcept 7 of 100
Migrated:view the updated version in /domainsThis /foundations page is legacy during migration.

Why It Matters for Modern Models

  • Stable Diffusion is a latent diffusion model: an autoencoder maps images ↔ compressed latent space where diffusion operates
  • VAEs underpin many multimodal encoders (audio, video latents) used as building blocks

What Tutorials Skip

What is still poorly explained in textbooks and papers:

  • Intuitive grasp of why ELBO works as both reconstruction + regularization
  • Visualizations of how the prior p(z) and posterior families affect sample quality/diversity

Interactive Visualization

Core Math (Optional Deep Dive)

If you want intuition first, start with the key equation and the visualization. Come back here for the full walkthrough.

Key Equation
logpθ(x)Eqϕ[logpθ(xz)]KL(qϕp(z))\log p_\theta(x) \ge \mathbb E_{q_\phi}[\log p_\theta(x\mid z)] - \mathrm{KL}(q_\phi\,\|\,p(z))

Latent variable model pθ(x,z)=p(z)pθ(xz)p_\theta(x,z) = p(z)p_\theta(x\mid z) with intractable posterior. Introduce variational encoder qϕ(zx)q_\phi(z\mid x) and maximize ELBO:

logpθ(x)Eqϕ(zx)[logpθ(xz)]KL(qϕ(zx)p(z))\log p_\theta(x) \ge \mathbb E_{q_\phi(z\mid x)}[\log p_\theta(x\mid z)] - \mathrm{KL}(q_\phi(z\mid x)\,\|\,p(z))

Reparameterization trick for Gaussian encoder:

z=μϕ(x)+σϕ(x)ϵ,ϵN(0,I)z = \mu_\phi(x) + \sigma_\phi(x)\odot\epsilon,\quad \epsilon\sim\mathcal N(0,I)

Canonical Papers

Auto-Encoding Variational Bayes

Kingma & Welling2013ICLR
Read paper →

Connections

Next Moves

Explore this concept from different angles — like a mathematician would.