Part XIII — Generative Models: VAEs, Flow Matching, Score Models & Diffusion Transformers · Chapter 6

Denoising Diffusion Probabilistic Models (DDPM)

Hook

The GAN's — short for Generative Adversarial Network — adversarial game is famously hard to keep stable. Diffusion models sidestep the contest entirely with a strange trick: deliberately destroy the data with noise, step by step, until nothing recognizable is left — then train a model to undo exactly one small step of that destruction at a time.

Intuition
forward (adding noise)start5.00x15.06x24.30x34.04x42.37reverse (denoising)start2.37x34.04x24.30x15.06x05.00
x0 = 5 → (forward) → reverse recovers exactly 5.00

The forward process (top row) is fixed and requires no learning at all — just mix in a little more noise at every step, according to a fixed schedule, until the data is almost unrecognizable. The reverse process (bottom row) undoes it one step at a time. With a perfect denoiser, reversing recovers the original value exactly — the same numbers, in reverse order.

Formalize

Forward, adding noise at step tt: xt=αtxt1+βtϵtx_t = \sqrt{\alpha_t}\, x_{t-1} + \sqrt{\beta_t}\, \epsilon_t, where βt\beta_t is how much noise this step adds and αt=1βt\alpha_t = 1-\beta_t. Reverse, removing it, given a predicted noise ϵ^t\hat\epsilon_t from a trained model:

xt1=xtβtϵ^tαtx_{t-1} = \frac{x_t - \sqrt{\beta_t}\,\hat\epsilon_t}{\sqrt{\alpha_t}}
  • xtx_t — the (increasingly noisy) value at step tt.
  • xt1x_{t-1} — the value one step earlier: less noisy, one step closer to the original data.
  • βt\beta_t — how much noise step tt adds to the signal, fixed by a schedule.
  • αt\alpha_t — shorthand for 1βt1-\beta_t: how much of the previous signal survives this step.
  • ϵ^t\hat\epsilon_t — the trained model's predicted noise at step tt, used to undo the forward step.
  1. Reverse is the forward equation, solved backward

    This is exactly the forward equation solved for xt1x_{t-1}.

  2. A perfect predictor exactly inverts it

    If ϵ^t\hat\epsilon_t equals the true ϵt\epsilon_t at every step, this exactly inverts the forward process.

  3. Training reduces to one question

    The entire training problem reduces to one question: can a network predict, from a noisy xtx_t, what noise was added to get there?

Play
reverse (denoising)start2.37x33.55x23.98x14.57x04.65
reconstructed x0 ≈ 4.653 (true x0 = 5) — error = 0.347

Drag the denoiser's quality down from perfect (1) toward clueless (0, always predicting zero noise). The reconstructed value drifts further from the true x0x_0 — but even at quality 00, it lands closer to 55 than the pure-noise starting point did, because the αt\sqrt{\alpha_t} scaling alone pulls values back toward a reasonable range at every step. A real diffusion model's whole job is training that noise predictor well enough to close this gap.

Worked example
  1. Forward — destroy the signal

    With noise schedule β=[0.1,0.2,0.3,0.4]\beta=[0.1,0.2,0.3,0.4] (so α=[0.9,0.8,0.7,0.6]\alpha=[0.9,0.8,0.7,0.6]) and fixed noise samples ϵ=[1,0.5,0.8,1.2]\epsilon=[1,-0.5,0.8,-1.2]:

    1. x1=0.9(5)+0.1(1)4.743+0.316=5.06x_1 = \sqrt{0.9}(5) + \sqrt{0.1}(1) \approx 4.743+0.316 = 5.06
    2. x2=0.8(5.06)+0.2(0.5)4.5260.224=4.30x_2 = \sqrt{0.8}(5.06) + \sqrt{0.2}(-0.5) \approx 4.526-0.224 = 4.30
    3. x3=0.7(4.30)+0.3(0.8)3.600+0.438=4.04x_3 = \sqrt{0.7}(4.30) + \sqrt{0.3}(0.8) \approx 3.600+0.438 = 4.04
    4. x4=0.6(4.04)+0.4(1.2)3.1280.759=2.37x_4 = \sqrt{0.6}(4.04) + \sqrt{0.4}(-1.2) \approx 3.128-0.759 = 2.37
  2. Reverse with a perfect denoiser

    Running the reverse formula with ϵ^t\hat\epsilon_t set to the exact same true noise, from x4=2.37x_4=2.37 backward:

    1. x3=(2.370.4(1.2))/0.6(2.37+0.759)/0.775=4.04x_3 = (2.37 - \sqrt{0.4}(-1.2))/\sqrt{0.6} \approx (2.37+0.759)/0.775 = 4.04
    2. x2=(4.040.3(0.8))/0.7(4.040.438)/0.837=4.30x_2 = (4.04 - \sqrt{0.3}(0.8))/\sqrt{0.7} \approx (4.04-0.438)/0.837 = 4.30
    3. x1=(4.300.2(0.5))/0.8(4.30+0.224)/0.894=5.06x_1 = (4.30 - \sqrt{0.2}(-0.5))/\sqrt{0.8} \approx (4.30+0.224)/0.894 = 5.06
    4. x0=(5.060.1(1))/0.9(5.060.316)/0.949=5.00x_0 = (5.06 - \sqrt{0.1}(1))/\sqrt{0.9} \approx (5.06-0.316)/0.949 = 5.00

    Exactly retraces those numbers backward.

  3. Reverse with a useless denoiser

    Same formula, but every ϵ^t=0\hat\epsilon_t=0, from x4=2.37x_4=2.37 backward:

    1. x3=(2.370)/0.63.06x_3 = (2.37-0)/\sqrt{0.6} \approx 3.06
    2. x2=(3.060)/0.73.66x_2 = (3.06-0)/\sqrt{0.7} \approx 3.66
    3. x1=(3.660)/0.84.09x_1 = (3.66-0)/\sqrt{0.8} \approx 4.09
    4. x0=(4.090)/0.94.31x_0 = (4.09-0)/\sqrt{0.9} \approx 4.31

    The right neighborhood, but nowhere near exact, because every step's error compounds into the next.

Checkpoint

Raise the denoiser’s quality until the reconstructed x0 is within 0.1 of the true value, 5.

reverse (denoising)start2.37x33.06x23.65x14.09x04.31
reconstructed x0 ≈ 4.307 — error = 0.693
Drag the slider to try it
Summary
xt1=xtβtϵ^tαtx_{t-1} = \frac{x_t - \sqrt{\beta_t}\,\hat\epsilon_t}{\sqrt{\alpha_t}}

No adversary, no minimax game — just a single, well-behaved supervised prediction task (predict the noise) repeated at every step, chained together to generate a full sample. That stability is the main reason diffusion models became the dominant approach for high-quality image generation. This closes Part IV: from raw pixels and sequences, through convolutions, recurrence, attention, and now generative models, every architecture in modern deep learning traces back to the same gradient descent and chain rule from Part II and III. Architectures get a second pass later in the course — GRUs, ResNets, BERT, Vision Transformers, and more — once evaluation, tuning, and a few more classical models have had their turn.