projects / proj-flag-007
Next task →
Projects/Generative AI/Train a diffusion model on CIFAR-10
Level 4 · advanced · ~40 h

Train a diffusion model on CIFAR-10

Implement and train a DDPM on CIFAR-10, derive the training objective from the variational bound, and compare sampler quality between DDPM and DDIM at equal network evaluations.
Add to portfolio →

Problem statement

  • 01Implement and train a DDPM on CIFAR-10, derive the training objective from the variational bound, and compare sampler quality between DDPM and DDIM at equal network evaluations.

Real-world motivation

  • 01Diffusion gives stable training and high sample quality; understanding the reverse-process derivation is essential to modifying it.

Learning objectives

  • 01Derive the ELBO and the simplified noise-prediction loss
  • 02Train a U-Net on CIFAR-10
  • 03Compare DDPM and DDIM sampling

Technical architecture

  • 01U-Net with residual and attention blocks
  • 02cosine beta schedule
  • 03time-step sinusoidal embeddings

Mathematical foundations

  • 01$q(x_t|x_0)=\mathcal{N}(\sqrt{\bar\alpha_t}x_0,(1-\bar\alpha_t)I)$
  • 02$L_{simple}=\mathbb{E}_{t,x_0,\epsilon}\lVert\epsilon-\epsilon_\theta(\sqrt{\bar\alpha_t}x_0+\sqrt{1-\bar\alpha_t}\epsilon,t)\rVert^2$

Dataset and sources

  • 01CIFAR-10 50k training images
  • 02CIFAR-10 10k test images for FID

Step-by-step tasks

  • 01Implement the forward diffusion process and verify marginals
  • 02Build the U-Net with time embeddings
  • 03Train the epsilon predictor with the simplified loss
  • 04Implement DDPM and DDIM samplers
  • 05Compute FID against the test set
  • 06Ablate the number of sampling steps

Implementation requirements

  • 01Use mixed precision training
  • 02Use EMA of model weights
  • 03Log samples every epoch

Testing requirements

  • 01Check the noise schedule is monotonic
  • 02Verify sample shapes and value ranges
  • 03Compare one-step denoising with analytic expectation

Evaluation metrics

  • 01FID
  • 02Inception Score
  • 03sample diversity
  • 04training loss

Expected outputs

  • 01trained checkpoint
  • 02sample grids
  • 03FID table
  • 04derivation notes

Common failure modes

  • 01variance schedule too aggressive destroys signal
  • 02insufficient sampling steps produce noisy samples
  • 03EMA update too fast degrades samples

Stretch goals

  • 01add classifier-free guidance
  • 02train a class-conditional model

Research extensions

  • 01study the ELBO gap between simplified and full objectives
  • 02compare score-based and DDPM parameterizations

GitHub submission requirements

  • 01Training and sampling code
  • 02FID evaluation script
  • 03Sample grids
  • 04Report with derivation

Completion rubric

  • 01derivation correct
  • 02forward process verified
  • 03training stable
  • 04FID reported
  • 05sampler comparison controlled

Submit when every rubric item is satisfied and your repository contains runnable code plus a reproduction command.