Let x be an observed datapoint and z∈Rd a latent variable with prior p(z)=N(0,I). A VAE uses an approximate posterior qϕ(z∣x)=N(μϕ(x),diag(σϕ2(x))) and decoder pθ(x∣z).
(a) Starting from logpθ(x), derive the evidence lower bound (ELBO) and prove that
logpθ(x)−ELBO(x)=DKL(qϕ(z∣x)∥pθ(z∣x))≥0.
State precisely why this justifies maximizing the ELBO. (6)
(b) For diagonal-Gaussian q and standard-normal prior, prove the closed form
DKL(N(μ,diag(σ2))∥N(0,I))=21∑j=1d(μj2+σj2−lnσj2−1).(6)
(c) Explain the reparameterization trick: write z=μϕ(x)+σϕ(x)⊙ϵ, ϵ∼N(0,I). Prove that for a differentiable f,
∇ϕEqϕ(z∣x)[f(z)]=Eϵ∼N(0,I)[∇ϕf(μϕ+σϕ⊙ϵ)],
and explain why the naive score-function (REINFORCE) estimator has higher variance in practice. (6)
(d) A student sets σj→0 for all j. Using the result of (b), state numerically what happens to the KL term as σj→0 with μj fixed, and explain the training consequence. (4)
Let pr be the real data distribution and pg the generator distribution.
(a) For the original (non-saturating not required) GAN value function
V(D,G)=Ex∼pr[logD(x)]+Ex∼pg[log(1−D(x))],
prove that the optimal discriminator is D∗(x)=pr(x)+pg(x)pr(x), and show that substituting D∗ yields
V(D∗,G)=2DJS(pr∥pg)−2log2.(8)
(b) Explain, using the result of (a), why vanishing gradients arise when pr and pg have disjoint supports, and how this connects to mode collapse. (4)
(c) The Wasserstein GAN replaces the objective with W(pr,pg)=sup∥f∥L≤1Epr[f]−Epg[f] (Kantorovich–Rubinstein). For two 1-D point masses pr=δ0, pg=δθ, compute W(pr,pg) and DJS(pr∥pg) as functions of θ, and use the two to argue why WGAN gives usable gradients where standard GAN does not. (5)
(d) State the role of the Lipschitz constraint and name one method used to enforce it. (3)
The DDPM forward process is q(xt∣xt−1)=N(1−βtxt−1,βtI) with schedule {βt}t=1T. Define αt=1−βt and αˉt=∏s=1tαs.
(a) Prove the closed-form marginal
q(xt∣x0)=N(αˉtx0,(1−αˉt)I),
by induction (or direct composition of Gaussians). (6)
(b) Using (a), write xt=αˉtx0+1−αˉtϵ, ϵ∼N(0,I). Given the simplified DDPM loss Lsimple=Et,x0,ϵ[∥ϵ−ϵθ(xt,t)∥2], explain what ϵθ predicts and why this is equivalent (up to weighting) to learning the score ∇xtlogq(xt∣x0). (6)
(c) With a linear schedule βt from β1=10−4 to βT=0.02, T=1000: qualitatively describe αˉt from t=0 to T, and explain why αˉT≈0 is required for sampling to start from pure noise. Compute numerically αˉt for a 3-step toy schedule β=(0.1,0.2,0.3). (6)
(a) (6)
Start with the identity for any qϕ:
logpθ(x)=Eqϕ(z∣x)[logqϕ(z∣x)pθ(x,z)]+Eqϕ(z∣x)[logpθ(z∣x)qϕ(z∣x)].(2 — inserting q and using p(x,z)=p(z∣x)p(x))
The first term is the ELBO; the second is DKL(qϕ(z∣x)∥pθ(z∣x)). (2)
Since logpθ(x) is constant in the expectation (does not depend on z), the identity holds; KL ≥0 by Gibbs/Jensen, so ELBO ≤logpθ(x). (1) Maximizing ELBO over θ,ϕ simultaneously (i) tightens the bound on the true log-likelihood and (ii) drives qϕ toward the true posterior — hence valid surrogate objective. (1)
(b) (6)
KL between two d-dim Gaussians N(μ,Σ1) and N(0,I):
DKL=21[tr(Σ1)+μ⊤μ−d−lndetΣ1].(3 — general Gaussian KL)
With Σ1=diag(σj2): tr=∑σj2, μ⊤μ=∑μj2, lndet=∑lnσj2, d=∑1. (2)⇒DKL=21∑j(μj2+σj2−lnσj2−1).■(1)
(c) (6)
Under z=μϕ+σϕ⊙ϵ with ϵ∼N(0,I), the pushforward of N(0,I) is exactly N(μϕ,diagσϕ2)=qϕ. (2) Therefore
Eqϕ[f(z)]=Eϵ[f(μϕ+σϕ⊙ϵ)].
The RHS distribution (N(0,I)) is independent of ϕ, so ∇ϕ passes inside the expectation (dominated convergence / differentiating under the integral):
∇ϕEqϕ[f]=Eϵ[∇ϕf(μϕ+σϕ⊙ϵ)].■(2)
Score-function estimator ∇ϕEq[f]=Eq[f(z)∇ϕlogqϕ(z∣x)] does not use ∇f; it treats f as a black-box weight, so its variance scales with the magnitude of f and does not shrink with a well-behaved gradient — empirically much higher variance. (2)
(d) (4)
As σj→0+: σj2→0 but −lnσj2→+∞, so the per-dim term 21(μj2+σj2−lnσj2−1)→+∞. (2) Thus KL diverges to +∞; the encoder becomes deterministic, ELBO →−∞, gradients blow up — training penalizes collapsing the posterior to a point. This is the KL regularizer's role: it keeps the latent stochastic and close to the prior. (2)
(b) (4)
When supports are disjoint, D∗ can be made 1 on real, 0 on fake exactly ⇒ DJS=log2, so V(D∗)=0 constant, and generator gradient ∇G through log(1−D) vanishes (saturation). (2) No useful signal reaches G; it cannot spread mass, and any narrow region that fools D is reinforced → generator maps to few modes = mode collapse. (2)
(c) (5)
For pr=δ0, pg=δθ: EM distance is ∣θ∣ (mass moved distance ∣θ∣): W=∣θ∣. (2) JS: for θ=0 supports disjoint so DJS=log2 (constant); at θ=0, DJS=0. (2)W(θ)=∣θ∣ is continuous with a.e. nonzero gradient sign(θ) pointing toward θ=0, while DJS is flat (zero gradient) for all θ=0. Hence WGAN provides usable gradients everywhere; standard GAN does not. (1)
(d) (3)
The ∥f∥L≤1 Lipschitz constraint is required for the Kantorovich–Rubinstein duality to equal W; without it the sup is unbounded. (1.5) Enforcement: weight clipping (original WGAN) or gradient penalty (WGAN-GP) / spectral normalization. (1.5)
(a) (6)
Base: x1=α1x0+1−α1ϵ1, matches αˉ1=α1. (1) Inductive step: assume xt−1=αˉt−1x0+1−αˉt−1ϵˉt−1. Then
xt=αtxt−1+1−αtϵt=αtαˉt−1x0+(αt(1−αˉt−1)ϵˉt−1+1−αtϵt).(2)
The two independent Gaussians sum in variance: αt(1−αˉt−1)+(1−αt)=1−αtαˉt−1=1−αˉt. (2) Mean coefficient =αˉt. Hence q(xt∣x0)=N(αˉtx0,(1−αˉt)I). ■(1)
(b) (6)ϵθ(xt,t) predicts the noise ϵ that was added to produce xt from x0. (2) Since xt=αˉtx0+1−αˉtϵ, we have ∇xtlogq(xt∣x0)=−1−αˉtxt−αˉtx0=−1−αˉtϵ. (2) Thus the score is a rescaling of −ϵ; predicting ϵ is equivalent to score matching with sθ=−ϵθ/1−αˉt, differing only by the t-dependent weight that Lsimple drops. (2)
(c) (6)αˉt=∏(1−βs) decreases monotonically from αˉ0=1 toward ≈0. Early β small ⇒ αˉt near 1 (little noise); late steps drive it to ~0. (2)αˉT≈0 makes q(xT∣x0)≈N(0,I) independent of x0, so sampling can begin from pure Gaussian noise (matching the prior). (2)
Toy schedule β=(0.1,0.2,0.3): α=(0.9,0.8,0.7).
αˉ1=0.9, αˉ2=0.72, αˉ3=0.504. (2)
[{"claim":"Diagonal-Gaussian KL to N(0,I) formula for mu=[1,2], sigma2=[0.5,1.5]", "code":"import sympy as sp\nmu=[sp.Integer(1),sp.