Generative Modeling
The core skill is distinguishing objective families, sampling paths and evaluation limits. One compact representative should be implemented well instead of reproducing every family.
Section 6 of 8 · 7 units · about 25 hours
By the end you can Derive and implement a compact VAE objective and sampler, expose posterior or mode collapse in a controlled run, and explain what the loss, reconstructions and samples cannot prove.
Units
- Autoencoders and latent-variable models3h
- The ELBO and reparameterized sampling4h
- Posterior collapse and decoder capacity3h
- GAN objectives, alternating updates and mode collapse4h
- Diffusion: forward corruption, reverse denoising and prediction targets5h
- Diffusion sampling schedules, cost and guidance3h
- Evaluating and comparing generative model families3h
Build it
Mini project · about 8 to 12 hours
Compact VAE with a controlled collapse study
Derive and implement a small VAE, then run a controlled study that produces posterior collapse on purpose, measures it per latent dimension and repairs it. Compare with a small GAN on a 2D mixture, and end with what the loss, reconstructions and samples cannot prove.
- 1Derive the ELBO for a diagonal Gaussian encoder, including the closed-form KL per dimension, and implement it with the reparameterization trick. Pass Deep-ML 393, and test your KL against
torch.distributions.kl_divergenceand a Monte Carlo estimate. - 2Train a small VAE on binarized MNIST, or on a 2D mixture if you only have a CPU, and log the reconstruction term, the total KL and the KL of each latent dimension every epoch.
- 3Produce collapse on purpose with a much stronger decoder or a large KL weight such as . Show most dimensions with KL near zero, and a resampling test: decoding fresh prior samples gives nearly the same output.
- 4Ablate decoder capacity or at three settings, and add KL annealing from 0 to 1 over a stated number of steps. Report active units, the dimensions whose KL exceeds a threshold you state, for each run.
- 5Report the test ELBO in nats per example beside reconstructions and samples, and give one way each of the three could mislead.
- 6Train a small GAN on an eight-Gaussian 2D mixture with alternating updates, and count the modes its samples cover with a fixed sample size and distance threshold, over training and two seeds.
What you hand in
- The VAE code with ELBO tests: Deep-ML 393, the KL checks and the resampling test.
- The collapse study: per-dimension KL plots, active-unit counts, the ablation and the annealing run, plus the GAN mode-coverage plot.
- A limits note on what the loss, reconstructions and samples cannot prove, citing your own runs.
How to check it
- Deep-ML 393: Implement VAE Loss (ELBO)
Its tests use a squared-error reconstruction term with the closed-form Gaussian KL.
- Self-grade with the rubric below
How it's graded
Objective
Pass: Deep-ML 393 passes, and the closed-form KL matches torch.distributions within float tolerance.
Great: The Monte Carlo KL estimate agrees within its standard error, and the note derives the per-dimension KL.
Controlled collapse
Pass: One run shows most dimensions with near-zero KL, and the resampling test confirms the decoder ignores .
Great: The ablation reports active units across two seeds and explains any setting that breaks the trend.
Repair
Pass: Annealing or a capacity change restores active units under the stated threshold.
Great: You report the repair's cost in ELBO and reconstruction, not only its benefit.
Mode coverage
Pass: GAN coverage of the eight modes is counted with a stated threshold and sample size.
Great: Coverage is tracked over training and across two seeds, and drops are tied to the alternating updates.
Honest limits
Pass: The note gives one way each of loss, reconstructions and samples can mislead.
Great: Each claim points to a run in your study that shows it.
Resources
- Understanding Deep Learning - generative modelsSimon J. D. Prince
Read Chapter 14 for evaluation limits, 15 for GANs, 17 for VAE and ELBO, and 18 for diffusion. Read Chapter 16 only for flow recognition. Use notebooks 17.1-17.3 and 18.1-18.4 as mathematical and visual practice.
- D2L - GAN and DCGAND2L authors
Use gan.md and dcgan.md for one bounded adversarial exposure. The required implementation remains a small VAE with separate reconstruction and KL terms on a two-dimensional mixture or binarized MNIST subset.
- Deep-ML candidate - VAE, GAN and diffusion problemsDeep-ML
After the platform admission check, use at most one of 393 VAE Loss, 1384 Reparameterization, 174 1D GAN or 303 Forward Diffusion as a changed-prompt drill.
- Stanford CS231n - diffusion assignment sliceStanford University
Use the Assignment 3 diffusion component only after the VAE gate if diffusion mechanics remain weak. It is not a second required generative implementation.
- Progressive Distillation for Fast Sampling of Diffusion ModelsarXiv
Read Section 4 only for the velocity parameterization and why it stays stable at zero signal-to-noise ratio. Leave Algorithms 1 and 2 and the distillation results for later.