Explain VAEs, ELBO, KL, and Reparameterization
GoogleMachine Learning Engineer · Technical ScreenLast updated
Derive and explain the theoretical foundations of Variational Autoencoders (VAEs), linking the Evidence Lower Bound (ELBO) to network architecture, gradient estimation via the reparameterization trick, and posterior collapse.
Scenario
You are designing a generative latent-variable model for high-dimensional sensor data x. You opt for a Variational Autoencoder (VAE) where latent variable z follows a standard normal prior p(z) = N(0, I), the generative distribution is parameterized by a decoder network p_theta(x | z), and the intractable true posterior p_theta(z | x) is approximated by an encoder network q_phi(z | x) = N(mu_phi(x), diag(sigma_phi(x)^2)).
Questions to Address
-
ELBO Derivation & Interpretation
- Starting from the marginal log-likelihood
log p_theta(x), derive the Evidence Lower Bound (ELBO). - Decompose the ELBO into the reconstruction term and the Kullback-Leibler (KL) divergence regularizer.
- Explain what each term encourages the model to do and why maximizing the ELBO is equivalent to minimizing
D_KL(q_phi(z | x) || p_theta(z | x)).
- Starting from the marginal log-likelihood
-
Reparameterization Trick
- Explain why direct backpropagation fails when sampling
z ~ q_phi(z | x). - Formulate the reparameterization trick for Gaussian posteriors and show how it separates stochasticity from network parameters
phito allow low-variance Monte Carlo gradient estimates.
- Explain why direct backpropagation fails when sampling
-
Closed-Form KL Divergence
- Give the analytical formula for
D_KL(N(mu, diag(sigma^2)) || N(0, I))in terms ofmu_jandsigma_jacrossJlatent dimensions.
- Give the analytical formula for
-
Posterior Collapse & Mitigations
- Define the phenomenon of posterior collapse (where
q_phi(z | x)collapses top(z)and the decoder ignoresz), common when pairing VAEs with powerful autoregressive decoders. - Discuss at least two practical mitigations (e.g., KL annealing/warmup, free bits / KL thresholding, decoder capacity adjustments).
- Define the phenomenon of posterior collapse (where
Hints
Hint 1
Use Jensen's inequality applied to log E_q[p(x, z) / q(z | x)] or expand log p(x) using the definition of KL divergence between q_phi(z | x) and p_theta(z | x).
Hint 2
Express z as a deterministic function of phi, x, and an auxiliary noise variable epsilon drawn from N(0, I).
Hint 3
Posterior collapse occurs when the decoder can model p(x) without conditioning on z, making D_KL drive toward zero early in training.
Follow-up questions
- How does the reparameterization trick compare to the REINFORCE (score-function) gradient estimator in terms of variance and applicability to discrete latent variables?
- How does changing the likelihood distribution p_theta(x | z) (e.g., Gaussian vs. Bernoulli) alter the reconstruction loss formulation?
- What is the beta-VAE formulation, and how does the hyperparameter beta trade off reconstruction fidelity against disentanglement?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.