4.5.11 · D4Generative Models

Exercises — Denoising diffusion probabilistic models (DDPM)

2,080 words9 min readBack to topic

This page is a self-test ladder. Each problem states cleanly what to do; the full worked solution hides inside a collapsible Solution callout so you can try first, then check. Levels climb from recognising the pieces to synthesising the whole DDPM machine. Every symbol used here was built in the Denoising diffusion probabilistic models (DDPM) parent note — but we re-anchor each one as it appears so you never hit an unexplained letter.

Before we start, one shared picture of the whole pipeline. Read it left-to-right for the forward (noising) process and right-to-left for the reverse (generating) process.

Figure — Denoising diffusion probabilistic models (DDPM)

Level 1 — Recognition

Exercise 1.1

In the forward step (recall: " of given ", the fixed noising rule), identify (a) the mean, (b) the variance, and (c) explain in one sentence why the mean is smaller than .

Recall Solution

(a) Mean . The notation always lists the mean in the middle slot. (b) Variance — the identity matrix means noise is added independently and equally to every pixel. (c) Because makes . Each step shrinks the old signal toward zero and replaces the lost "energy" with fresh noise, so total variance stays near instead of exploding.

Exercise 1.2

Given , compute and then .

Recall Solution

so . . Reading: after 3 steps only of the original signal scale survives. (Verified.)


Level 2 — Application

Exercise 2.1

A pixel has clean value . With , and a drawn noise , compute the noised value using the closed-form jump introduced above, .

Recall Solution

, and . . The signal contributes ; the noise dominates with . (Verified.)

Exercise 2.2

Using the same , , and the true , recover from the inversion .

Recall Solution

We get back the original exactly. This is the whole idea of noise-prediction: if the network can name the that was added, algebra recovers the clean pixel. (Verified.)

Exercise 2.3

The variance schedule is linear from to over steps. What is (the midpoint)?

Recall Solution

Linear means . At : fraction . . So the midpoint injects about variance per step. (Verified.)


Level 3 — Analysis

Levels 3 uses the reverse posterior — the rule for stepping backwards one notch (from to ) when we happen to know the clean image . The parent note shows (via Bayes' theorem) that this is itself a Gaussian, . Two new symbols come from it:

Exercise 3.1

Show that if , then the forward step gives too. (This is the "variance-preserving" property.)

Recall Solution

and are independent, so variances add after scaling: Substituting , : The variance is a fixed point at . Why the design needs this: without it, variance would drift and the final would not match the we sample from at generation time. (Verified.)

Exercise 3.2

Compute the posterior variance when , , . Then explain why here.

Recall Solution

It is smaller than because the ratio . Meaning: when we run the reverse step knowing , we are more certain than the raw forward noise level — conditioning on the endpoint shrinks the uncertainty. (Verified.)

Exercise 3.3

The reverse posterior mean is With , compute .

Recall Solution

Coefficient of : Coefficient of : The posterior mean is a weighted blend of "where we came from" () and "where we are" (). The figure below plots exactly this blend: the red dot (the mean) sits between the yellow and the blue , pulled harder toward because its weight () is the larger. (Verified.)

Figure — Denoising diffusion probabilistic models (DDPM)

Read the figure this way: the arrow lengths are the two weights. The mean is not the midpoint — it lands closer to precisely because . Whenever is large (early in noising), the weight shifts back toward instead.


Level 4 — Synthesis

Exercise 4.1

Derive the noise-prediction reparameterisation of the mean. Start from the posterior mean (Ex 3.3) and substitute to show

Recall Solution

What we do & why: we want the mean to depend only on the known and the predictable , not on the unknown clean . So we replace using the inversion of the closed-form jump.

Step 1 — substitute. Put into the first term of : Step 2 — use the product identity , hence . The first term becomes Step 3 — collect the coefficients. Add the piece above to the second term of , whose coefficient is . Total coefficient: The numerator is (using and ). So the coefficient collapses to Step 4 — collect the coefficient. Only the first term carries : Step 5 — assemble. Combining Steps 3 and 4:

Numeric sanity check. Take .

  • New form:
  • Original via : ; then Both equal — the reparameterisation is exact. (Verified.)

Why bother? Predicting is a fixed-scale, unit-variance target at every , which trains far more stably than predicting or whose scale drifts with . This is the bridge to .

Exercise 4.2

A full training step (following the parent's worked example). Given , , , drawn , and a network output . Compute and the per-pixel loss .

Recall Solution

Loss That is what backpropagation drives toward . (Verified.)


Level 5 — Mastery

Exercise 5.1

Sanity of the whole chain. Suppose with . (a) Compute . (b) What is the effective signal-to-noise contribution, i.e. the mean-coefficient and noise-coefficient at the final step? (c) Interpret: is "enough noise"?

Recall Solution

(a) , , . (b) (signal), (noise). (c) At the signal still contributes — the image is very much not pure noise. For to be indistinguishable from we need , which is why real DDPMs use with tiny . (Verified.)

Exercise 5.2

Connecting the ideas. In one sentence each, say which mechanism from these vault topics DDPM borrows: (i) Variational Autoencoders (VAE), (ii) Markov Chain Monte Carlo, (iii) U-Net architecture, (iv) Classifier-free guidance, (v) Latent diffusion models.

Recall Solution

(i) VAE — the training loss is a variational lower bound on , exactly the VAE idea of bounding an intractable likelihood. (ii) MCMC — the reverse process is a Markov chain whose repeated sampling walks noise back to data, echoing sampling-by-chain. (iii) U-Net — the network is almost always a U-Net, chosen because denoising needs both fine detail (skip connections) and global context (bottleneck). (iv) Classifier-free guidance — steers toward a text/class condition by mixing conditional and unconditional predictions. (v) Latent diffusion — runs the whole DDPM machinery in a compressed latent space instead of pixels, for speed.

Exercise 5.3

Prove a limit. Show that as the schedule pushes , the closed-form marginal converges to .

Recall Solution

The mean is . As , , so mean for any finite . The variance is . As , this . Therefore independent of the starting image. This is the guarantee that lets generation begin from a fresh draw with no memory of any particular datum. (Verified.)

Recall Quick self-quiz

Is a sum or a product of the ? ::: A product, . Why scale by ? ::: To keep total variance (variance-preserving). What does the network predict? ::: The noise that was added, not the clean image. As , what? ::: , standard Gaussian.