Drawing from a hat of noise
Before Ganesh Chaturthi, a sculptor in a small workshop makes one idol after another. Every morning his helper hands him a lump of clay. No two lumps are the same: one is a little bigger, one a little lopsided, one a little wetter.
The sculptor's hands make the same moves every time. Yet every idol comes out slightly different, and every one of them still looks like Ganesha. The skill is fixed. The lump is random. Put the two together and new idols keep coming.
The question. How can a machine draw a face that has never existed?
Here is the whole idea of this unit in one line: to create is to sample. A machine that creates is a machine that takes easy randomness — the lump of clay — and turns it into something that looks like the real data. We call such a machine a generator. The randomness goes in, the sculptor's fixed skill is a function , and a new example comes out: .
By hand, with heights. Say the heights of grown men in a town follow a bell curve with mean 170 cm and spread 7 cm, written . How do we make up a new, realistic height? Draw a standard random number from — the easiest bell curve there is, centred at 0 with spread 1 — and then stretch and shift it:
Four draws of the hat give . The machine turns them into
Four new men who never existed, each with a believable height. The skill (, then ) never changed. Only the lump did.
Not every shape is a bell. Waiting times at a bus stop, say, follow an exponential curve: short waits are common and long waits are rare. With the chance that the wait is at most minutes is . Now take the plainest noise of all, a number spread evenly between 0 and 1, and solve for :
With : minutes. This trick is called the inverse CDF (the CDF is the "chance of at most " curve, ). It works for any shape of data in one dimension: run the curve backwards on even noise.
The hard part. For heights and waiting times someone can write the curve down. For pictures, nobody can. A 20 × 20 grey picture is already 400 numbers, and there is no formula for "all the pictures that look like a face". So the generator has to be learned from examples. That is what the whole unit is about: two ways to learn the sculptor's hands — the VAE (Act II) and diffusion (Act III).
Look at the curve as a funnel. Where it is steep, a narrow band of inputs is stretched over a wide band of outputs, so the balls spread thin. Where it is flat, a wide band of inputs is squeezed into a narrow band of outputs, so the balls pile up. So the curve decides where the pile is high and where it is low: output density = input density ÷ slope. The inverse CDF picks exactly the curve whose slope makes the pile come out right. A learned generator does the same thing in hundreds of dimensions, with a neural network as the curve.
Four ways to learn the sculptor's hands. Every modern generator turns noise into data. They differ in how the noise goes in and how the machine is trained.
| family | how it draws | where the noise goes in | good at | weak at |
|---|---|---|---|---|
| autoregressive (Unit 19) | one piece at a time, each piece chosen from a probability list | a dice roll at every token | text; exact likelihood | slow: one step per piece |
| VAE (§3–§7) | pick a point on a small map, decode it in one go | the point | fast; a smooth map you can walk | blurry pictures |
| GAN | one pass of a generator network | a random vector | sharp pictures, fast | unstable training; can forget whole kinds of data |
| diffusion (§8–§13) | start from static, remove a little noise many times | the starting static, and a little at every step | sharp, varied pictures; easy to steer | many steps (§12 makes it faster) |
A GAN in one paragraph. A GAN (a generative adversarial network) trains two networks against each other, like a forger and a detective. The forger turns noise into fake pictures. The detective looks at real pictures and fakes and says "real" or "fake". The forger improves by fooling the detective, the detective improves by catching the forger. It gives sharp pictures, but the contest is hard to balance, and the forger may learn to draw only a few kinds of picture that fool the detective. We will not build one here: the VAE and diffusion are the ones whose maths this course has prepared you for.
Rule of thumb. Text: autoregressive. A fast generator with a smooth map of the data: VAE. The best pictures today: diffusion — often run inside a VAE's map (§13).
A machine that hands back the training pictures is not creating — it is copying. We want new examples that come from the same distribution as the training data: new heights that are believable, not the heights of the men we measured. A generator is judged by whether its samples look like they came from the same hat, not by whether they match any one example.
A generator is a fixed function applied to fresh noise. In one dimension we can write the function down: stretch-and-shift for a bell curve, the inverse CDF for anything else. For pictures the function must be learned — and learning it is the whole art.
In the heights machine you change the curve from to . What happens to the green pile of outputs?
In the waiting-times machine , where do most of the outputs pile up, and why?
If you want the algebra · 2 proofs, step by step
Claim. Let be a CDF that rises steadily (so it has an inverse), and let be spread evenly on . Then has exactly the CDF .
Claim. If with increasing, and has density , then has density at .
The road ahead. The unit has four acts.
- To create is to sample (§1–§2): the noise machine, and the two facts about Gaussian noise that everything later uses.
- Squeeze, then rebuild (§3–§7): the autoencoder, the VAE's cloud, the reparameterisation trick, the ELBO, and walking the map of faces.
- Noise in, noise out (§8–§12): diffusion — destroy a picture with noise, learn to guess the noise, the score as a compass, walk back from static, and the fast jump.
- Steering, and the whole course (§13–§14): steering with words, latent diffusion, and every tool of the course inside the two machines.
In one sentence: A generator is a sculptor's fixed skill applied to a random lump of clay — with fresh noise — and since nobody can write down for pictures, the machine has to learn it.
That was section 1. The rest of the unit opens when you unlock it.
13 more sections and the practice arena — 14 widgets, 32 checks and 16 solved problems in the whole unit (this preview had 1 widget and 2 checks).
- 2
The Gaussian toolkit for noise
- 3
The autoencoder: squeeze and rebuild
- 4
The VAE: a cloud, not a point
- 5
The reparameterisation trick
- 6
The ELBO: the score a VAE maximises
- 7
Walking the latent map
- 8
Forward: destroy a picture one small step at a time
- 9
The denoiser: guess the noise
- 10
The score: a compass pointing at the data
- 11
Walking back from static
- 12
Faster: DDIM and the smooth path
- 13
Steering with words: guidance and latent diffusion
- 14
What to carry forward — and the whole course inside one picture
- 15
Practice arena — sixteen problems, solved in full
Unlock this unit for ₹299, or all seven paid units for ₹999 — one-time payment, full refund within 7 days. See pricing.