The autoencoder that learns a distribution instead of a point — so the space between examples becomes generative.
A plain autoencoder maps each input to a single point in latent space. Nothing forces those points to be arranged sensibly, so the gaps between them decode to garbage — the space is compressive but not generative.
A VAE changes the output of the encoder. Instead of one code, it emits the parameters of a distribution: a mean vector μ and a variance (usually as log σ²). You then sample a latent vector from that Gaussian and decode the sample. Because the same input maps to a small cloud rather than a dot, the decoder is forced to make every point in the neighbourhood decode to something plausible.
A second force does the rest: a KL penalty pulls all those little clouds toward a shared standard normal prior. The clouds overlap into one continuous, gap-free region. Now you can sample 𝑧 ~ N(0, I), decode, and get a new, never-seen example — that is the generative part.
qφ(z|x) outputs two vectors, μ(x) and log σ²(x), not a code. Predicting the log variance keeps it unconstrained and numerically stable, since exp() guarantees positivity.
z = μ + σ ⊙ ε, with ε ~ N(0, I). Randomness is pushed into an input ε, so the path from loss to μ and σ is deterministic and backprop works. Sampling directly from q would block gradients.
Reconstruction loss says “be faithful to this input.” KL divergence says “stay close to the prior.” Training is the negotiation between fidelity and a well-shaped latent space.
β-VAE weights the KL term. Raise β and you get a smoother, more disentangled latent space but blurrier outputs. Lower it and you drift back toward a plain autoencoder that cannot generate.
Why can’t you just sample z directly from qφ(z|x) and train with backprop — what specifically breaks, and how does the reparameterization trick repair it?
Hint: ask where the randomness lives. Is a sampling operation a differentiable function of μ and σ, or is it a discontinuous jump? Where must ε sit for the chain rule to survive?
Suppose you train a VAE with the KL term deleted (β = 0). It reconstructs beautifully. Why does sampling z ~ N(0, I) and decoding still produce garbage?
Hint: with no pull toward the prior, where do the encoder’s clouds end up, and how wide do they get? What does the decoder then know about the region you’re sampling from?
VAE samples are famously blurrier than GAN samples. Trace that blur back to a specific term in the objective — and say when you’d still choose a VAE over a GAN anyway.
Hint: think about what minimising an expected pixel-wise reconstruction loss does when several plausible outputs exist. Then weigh it against training stability, a usable encoder, and explicit likelihood bounds.