↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

What a diffusion model is

A diffusion model generates images by learning to undo noise. A fixed forward process adds a little Gaussian noise to an image at each of steps until nothing of the image is left; a network learns the reverse process, one small denoising step at a time, so that starting from pure noise and running all steps backwards gives a new image. No adversary and no explicit density are needed: training is plain regression on noise.

This tab records DDPM (denoising diffusion probabilistic model) as Ho, Jain and Abbeel released it for CIFAR-10: the google/ddpm-cifar10-32 checkpoint, a 35.7 M-parameter U-Net that works directly on 32 × 32 RGB pixels with steps. The page noises four CIFAR-10 test images (a ship, an automobile, a frog and a horse), shows what the U-Net predicts for each, and replays one full 1000-step sampling run of 16 images.

The noise schedule and forward noising

Each forward step scales the image down a little and adds noise of variance :

The Noise schedule panel plots the linear schedule DDPM uses, rising from 0.0001 to 0.02, with and , where . Because a sum of Gaussians is Gaussian, any can be drawn from the clean image in one jump:

The Forward noising panel draws exactly this sum for the chosen image and , and the strip below it shows the same image at all seven recorded timesteps. The two weights are the cosine and sine of one angle, so the signal fades as the noise grows: at , . The page counts from 0 to 999, as diffusers does; the paper counts from 1 to 1000.

Predicting the noise

Ho et al. let the network predict the noise that was added, rather than the clean image or the mean of the next step, and trained it with a simplified loss: pick an image, a timestep and a noise sample, noise the image in one jump, and regress.

This is the variational bound of the model with its per-step weights dropped, which puts more weight on the harder, noisier steps. Predicting is also predicting the score: , the link to Song and Ermon's score-based models that Ho et al. made explicit.

The Noise prediction panel sets the true beside the U-Net's , maps their difference, and turns into an estimate of the clean image, clipped to :

The recorded loss runs the opposite way to the picture's difficulty. For the ship it is 0.4961 at , 0.0086 at and 0.0001 at . At the input is almost all noise, so can nearly be read off it; at the noise is a faint layer of standard deviation 0.01 that is hard to separate from the image's own texture, but an error there barely moves .

The U-Net

One network serves all 1000 steps. The U-Net panel shows its four levels, 128, 256, 256 and 256 channels at 32, 16, 8 and 4 pixels, with two ResNet blocks per level on the way down and three on the way up. Each down block's output is saved and concatenated onto the matching up block's input (the arcs), so the up path sees fine detail the down path has already compressed. Ho et al. built it after PixelCNN++ with group normalisation throughout, and added self-attention at 16 × 16.

The timestep enters every ResNet block. becomes a 128-value sinusoid, as positions do in a transformer, and an MLP (Linear 128 → 512, SiLU, Linear 512 → 512) turns it into an embedding. Pick the ResNet block to see one stage by stage: GroupNorm over 32 groups, SiLU, a 3 × 3 convolution, then a per-channel bias projected from the timestep embedding, a second norm, SiLU and convolution, and a 1 × 1 shortcut because it goes from 128 to 256 channels. That bias is how the same weights do different work at and . The Self-attention block treats the 16 × 16 = 256 pixels as tokens with one head of 256 dimensions, so any pixel can look at any other.

The reverse process

Sampling starts from and takes all 1000 steps. Each step asks the U-Net for , forms , and moves to the mean of the forward process's posterior with in place of , plus fresh noise:

The Reverse process strip shows one of the 16 samples (seed 0) at 28 of the 1000 steps: , , , the two coefficients of , the noise and . The last step adds no noise. Ho et al. found that a variance of and the posterior's own, smaller variance gave similar samples; this checkpoint uses . The filmstrip of shows the order in which the picture forms; Ho et al. observed the same thing across many samples, large-scale features first and fine detail last.

Where DDPM came from

Sohl-Dickstein et al. proposed learning to reverse a diffusion process in 2015. Song and Ermon's noise-conditional score networks (2019) sampled by following learned gradients of the log density at falling noise levels. DDPM (2020) joined the two lines with the noise-prediction loss and reached an FID of 3.17 on CIFAR-10, the paper's headline result. Nichol and Dhariwal then learned the variances and used a cosine schedule, and Song et al. described both families as discretisations of one stochastic differential equation.

Two costs remained: 1000 network calls per image, and a network working on every pixel. DDIM's deterministic sampler and latent diffusion answer them; see the SD 1.5 tab. The DiT tab replaces the U-Net with a transformer.

Papers

  1. Denoising Diffusion Probabilistic Models Jonathan Ho, Ajay Jain, Pieter Abbeel · NeurIPS 2020 DDPM: the linear schedule, the noise-prediction loss, the U-Net and the 1000-step sampler this tab records, with the CIFAR-10 checkpoint it runs.
  2. Deep Unsupervised Learning using Nonequilibrium Thermodynamics Jascha Sohl-Dickstein, Eric A. Weiss, Niru Maheswaranathan, Surya Ganguli · ICML 2015 The first diffusion probabilistic model: destroy structure with a fixed forward process and learn to reverse it.
  3. Generative Modeling by Estimating Gradients of the Data Distribution Yang Song, Stefano Ermon · NeurIPS 2019 Score matching at many noise levels and annealed Langevin sampling, the score-based view that noise prediction turns out to share.
  4. U-Net: Convolutional Networks for Biomedical Image Segmentation Olaf Ronneberger, Philipp Fischer, Thomas Brox · MICCAI 2015 The encoder–decoder with skip connections between matching resolutions that the denoiser is built on.
  5. Improved Denoising Diffusion Probabilistic Models Alex Nichol, Prafulla Dhariwal · ICML 2021 Learned reverse variances and the cosine schedule; fewer sampling steps for the same quality.
  6. Score-Based Generative Modeling through Stochastic Differential Equations Yang Song et al. · ICLR 2021 DDPM and score-based models as two discretisations of one SDE, with a deterministic probability-flow ODE alongside.

See also