The World’s Smallest Diffusion Model
W01 · Part 3 — two data points, one line of Bayes, a complete generative model
Uma Satyaranjan · Soma S Dhavala
Invalid Date
The pitch
A diffusion model turns pure static into an image. It does exactly one thing, about a thousand times:
subtract a little noise, correctly.
Everything in this deck is computed exactly — no neural network anywhere. The demos are on the course site.
Our dataset: two points
Samples from an unknown distribution; task: produce more of the same. Today:
- Generating = flipping a coin — that is why it is the right dataset: nothing can hide
- You already know one generative model: fit by MLE, then sample
- Module 1: MLE minimizing
Why images break the direct approach
- A RGB image lives in a space with configurations
- Almost all of them are static — random pixels never make a face
- Real data is a vanishingly thin filament of the space
Writing down and fitting it directly is hopeless — the curse of dimensionality (Module 1).
The diffusion idea
- Destroying structure with noise: easy, fully understood
- It always ends somewhere known — a Gaussian
- Then learn to walk backwards
Watch noise accumulate
One point at , kicked times by noise of size : spread . Any kick distribution → same Gaussian (CLT).
Forward: noise melts the two points
- Two spikes → two bumps → one bell
- By , indistinguishable in practice from
Structure destroyed. Destination known.
The inverse problem
You observe a noisy . What was the clean point? Best guess under squared error is the posterior mean .
For the two-point prior, Bayes’ rule gives it in closed form:
One line of algebra — Exercise 1, do it tonight.
The punchline
- The optimal denoiser is a tanh — produced by nothing but probability
- : hard threshold — snap to the nearer point
- : shrink to — trust the prior, not the observation
Denoising = knowing the score
Differentiate and compare — Tweedie’s formula:
- The score points toward where noised data is denser
- Denoising and score estimation are the same problem — the hinge of Modules 3–4
Run the diffusion backwards
Anneal downward on a grid, nudging along the score:
What you just saw
- Particles start as pure noise
- The cloud splits, condenses, lands on the two data points
- Generation — with every step computed exactly, no neural network
The whole pipeline: noise the data → learn to denoise → run it backwards.
So where do neural networks come in?
For images, has no usable formula. The network’s only job:
— to be the tanh we can no longer derive. Everything else survives unchanged.
The course, mapped onto today
| “Produce more samples”; why direct density estimation fails |
M1 Foundations |
| Mixture, conditioning, |
M2 Gaussians & noise |
| The grid; denoising as the training target |
M3 DDPM |
| Score, Tweedie’s formula |
M4 Score matching |
| Noise levels as a continuum; densities evolving |
M5 SDEs, Fokker–Planck |
| The reverse update; probability-flow ODE |
M6 Reverse-time dynamics |
Tonight: read the companion note, play with the demos, and derive the tanh yourself.
Next lecture — Module 1: why maximum likelihood is KL divergence in disguise.