4.5.10 · D4Generative Models

Exercises — Diffusion models forward - reverse process

2,241 words10 min readBack to topic

Before we begin, one shared cheat-sheet of symbols (so nothing is used unexplained):

Figure — Diffusion models forward - reverse process

The figure above is our reference picture: signal (the mint bar) shrinks like , noise (the coral bar) grows like , and together their squared heights always add to . Keep it in mind — most problems are just "read off one of these two bars".


Level 1 — Recognition

Exercise 1.1

State, in one line each, what these three quantities mean: , , .

Recall Solution
  • ::: the variance of the fresh noise added at step (small, e.g. to ).
  • ::: the fraction of the previous signal's variance kept after step .
  • ::: the total fraction of the original signal surviving after steps — a running product of all keep-fractions.

Exercise 1.2

Given , , , compute and then .

Recall Solution

WHAT: convert each to a keep-fraction, then multiply them. WHY multiply: signal surviving three steps is (survive step 1) (survive step 2) (survive step 3). So about of the original signal variance remains after three steps.

Exercise 1.3

In the loss , what is the network trying to predict, and what does the double-bar-squared measure?

Recall Solution
  • The network predicts ==the noise == that was mixed into not the clean image.
  • is the squared Euclidean distance: sum over all pixels of (true noise predicted noise). It is only when every pixel's noise guess is exact.

Level 2 — Application

Exercise 2.1

Using , write the direct-sampling formula for in terms of and , with the two coefficients filled in numerically.

Recall Solution

WHAT: plug into . Read it off the figure: mint bar , coral bar , and . ✔

Exercise 2.2

The signal-to-noise ratio (SNR) of is (signal amplitude over noise amplitude). Compute the SNR at and at .

Recall Solution

WHY this ratio: it directly compares the two bars in our figure — how loud the signal is versus the noise. Early on the signal is ~2.6× louder than noise (digit recognisable); near the end noise is ~30× louder (essentially pure noise). This is exactly the parent note's MNIST intuition.

Exercise 2.3

Given a noisy (so ), and suppose the network's guess is perfect: . Recover .

Recall Solution

WHAT: use . With a perfect noise prediction, the reconstruction is exact — a good sanity check that the algebra closes.


Level 3 — Analysis

Exercise 3.1

Reproduce the parent-note reverse-step number. At : , , . Compute the two constants in

Recall Solution

WHAT: evaluate the outer scale and the inner noise coefficient . So — matching the parent note's . WHY: we subtract the estimated noise, then rescale by to restore the signal amplitude that the forward step shrank.

Exercise 3.2

Compute the reverse-step variance at , given additionally (and , ).

Recall Solution

WHY : knowing (and implicitly via the network) removes some uncertainty, so the reverse conditional is tighter than the raw forward noise . The sampled next state is with .

Exercise 3.3

Show algebraically that the coefficients in the direct-sampling formula always satisfy , and explain what this guarantees about the variance of when has unit variance.

Recall Solution

WHY it matters: if and is independent with , then So the total variance stays pinned at for all — this is exactly the reason we shrink by instead of just adding noise. Picture the two bars: their squared heights always sum to the same fixed total. This is the analysis-level payoff of the " shrink" design.


Level 4 — Synthesis

Exercise 4.1

Chain three forward steps by hand with . Compute two ways: (a) as a product of 's, and (b) by composing the single-step formula symbolically, confirming they agree. Then give the direct coefficient .

Recall Solution

(a) , so . (b) Composing: . The -coefficient squared is . ✔ Same answer — this is the whole point of the reparameterisation trick: nested single steps collapse into one product. Direct coefficient: , and the noise coefficient .

Exercise 4.2

A constant schedule for all gives . If we want ("indistinguishable from pure noise") with , find the smallest constant (to 4 decimals) that achieves it.

Recall Solution

WHAT: solve . Take logs: , so . So . WHY this is instructive: it shows a single tiny across 1000 steps already crushes the signal to — matching why real schedules end near (even more aggressive) and .


Level 5 — Mastery

Exercise 5.1

Full end-to-end trace of one training step and one denoising step, all numbers concrete. Setup: scalar toy data , timestep with , , , and a drawn noise value . (a) Form . (b) A perfect network returns ; compute the loss . (c) Compute the reverse mean . (d) With and a drawn , compute the sampled .

Recall Solution

(a) Noise the data. , . (b) Loss. — a perfectly trained net has zero loss on this sample. ✔ (c) Reverse mean. Inner coefficient ; outer scale . (d) Sample. . WHY the wobble past 1.0: the reverse step is stochastic (except at ) — that injected term is what gives generation its diversity. On average, though, is pulling back toward the clean signal.

Exercise 5.2

Sanity-check the whole design: prove that if (perfect prediction) and we plug the true -form into , the reverse mean equals the true posterior mean . Do it for the scalar case , with .

Recall Solution

Route A — network form. From 5.1(c) with these same numbers, . Route B — true posterior . Coefficient of : . Coefficient of : . The two routes agree to ~3 decimals ( vs ; the tiny gap is because these hand-picked values are not perfectly self-consistent, i.e. exactly). WHY this matters: it confirms the noise-prediction parameterisation is not a hack — it reproduces the exact Bayes-optimal reverse mean when the network is perfect.


Recall Quick self-check summary

What always sums to 1 across the two coefficient bars? ::: , keeping . Why predict not ? ::: noise is uniform across timesteps/domains, easier to learn; is recovered from it. Why is ? ::: conditioning on removes uncertainty, tightening the reverse variance. Signal survival across steps is ______ ? ::: multiplicative — a product of , not a sum of .

See also: Langevin dynamics (the score-based view of these reverse steps), DDIM sampling (a deterministic reverse process — drops the term), Classifier-free guidance (steering the reverse mean), Variational autoencoders (the ELBO cousin of the diffusion loss), and the parent topic note.