Part I · Ch. 1 — The Big Picture

Part I · Chapter 1 of 8

The Big Picture

Images as points, apples as a neighborhood, and why we add noise on purpose


Apple, static, apple

The whole series fits in one picture. We start with an apple. We slowly turn it into random static, the gray snow an old television showed when it had nothing to display. Then we turn that static back into an apple. It isn't the apple we started with. It's a brand-new one, a fruit that never existed and that nobody photographed, and it still looks believable.

This chapter builds that picture from nothing, so that by the end you can state the question the rest of the book answers. There's one piece of linear algebra in the middle. It's the idea the whole field rests on, and it's easier than its reputation.

Three panels in a row on a dark background. On the left, a golden-amber apple with a gray stem and a small mint leaf, labeled 'a real apple' and 'one of the training images'. A muted gray arrow points right, labeled 'forward process' above and 'Ch. 2' below, into the middle panel: a square field of gray and white static squares, labeled 'pure static' and 'no apple left in it at all'. A mint-green arrow points right from the static, labeled 'reverse process' above and 'Ch. 3, 5' below, into the right panel: a mint-green apple of a slightly different shape, labeled 'a brand-new apple' and 'never photographed, never stored'.
The spine of the whole book. Left to right: a real apple is destroyed into static, and static is rebuilt into a different apple. Chapter 2 owns the gray arrow, Chapters 3 and 5 own the mint one.

What we're asking for

We want a machine that hands us a brand-new apple, one that never existed and still looks real. A machine that produces fresh examples of a thing, rather than sorting or labeling things it is shown, is called a generative model. Each thing it produces is a fresh sample, and in this book that sample is always an apple.

To learn what an apple is, it has to be shown apples, and they have to be all different. Red, green, golden. Big, small, spotted. Photographed from the side and from above. From that variety it can pull out what an apple is: the round body, the dimple at the top, the stem. If every training photo were the same apple on the same table in the same light, the model could not tell which parts are "apple" and which parts are just "that Tuesday afternoon".

A rounded dark panel holding a three-by-three grid of nine simple apple drawings. They differ deliberately: a plain amber one, a tall mint-green one, a wide squat amber one, a small tilted amber one, a big mint-green one with dark speckles, an amber one tilted the other way with no leaf, a small speckled mint-green one, a large tilted amber one with no leaf, and a small speckled mint-green one. Beneath the panel: 'nine of the training apples — no two alike'. To the right, a short muted rule and two stacked labels: 'what stays the same' in white with 'round body, dimple, stem' in mint below it, and 'what varies' in white with 'color, size, angle, markings' in amber below it.
Nine apples, no two alike. What is common to all nine (mint) is the concept. What differs between them (amber) is accident. In Chapter 7, when we teach a model one specific apple variety, that distinction decides whether it learns "apple" or "apple on a wooden table".

An image is a point

To a computer, an image is a list of numbers. A pixel in a black-and-white image is a single number for brightness, running from 0 (black) to 1 (white). Take a tiny image, two pixels by two pixels, holding these four brightnesses:

$$\begin{bmatrix} 0.9 & 0.2 \\ 0.1 & 0.8 \end{bmatrix}$$

In words: a two-by-two grid of brightnesses. A near-white pixel in the top-left, a dark one in the top-right, a darker one in the bottom-left, and a light one in the bottom-right.

To hand that grid to a computer we flatten it. Read the pixels left to right along the top row, then left to right along the bottom row, and write them out in one line. Top-left first, so $0.9$, then $0.2$, then $0.1$, then $0.8$. That gives us our clean image, which we will call $\mathbf{x}_0$, read "x-zero, the clean image". The subscript zero will earn its keep in the next chapter:

$$\mathbf{x}_0 = [\,0.9,\; 0.2,\; 0.1,\; 0.8\,]$$

In words: the same four brightnesses, in reading order, written as one list of four numbers. Nothing was lost and nothing was added. Only the shape of the container changed.

A list written out like that has a name, and the name is a vector. That is the whole definition: an ordered list of numbers, and the order matters. Swap the last two entries and you have a different image. I'll use "list" and "vector" interchangeably from here.

A list of numbers is also a point. Two numbers are a point on a flat map: go $0.9$ along, $0.2$ up. Three numbers are a point in the room you are sitting in: along, up, and back. Four numbers are a point in a four-dimensional space, which nobody can picture and which behaves arithmetically like the first two cases. The word dimension gets used loosely everywhere, so pin it down here. One dimension is one number in the list, which is one independent direction you are free to move in. You needed four numbers to say where the point is, so the space it lives in has four. The list and the point are the same object, written two ways. (If lists-as-arrows is new, the math toolkit in the AI/ML book builds it from scratch, and numbers that point does the same for text.)

Three panels. Left: a two-by-two grid of gray squares, near-white 0.9 top-left, dark 0.2 top-right, near-black 0.1 bottom-left, light 0.8 bottom-right, captioned 'a 2 x 2 grayscale image' with '0 = black, 1 = white' above. Middle: a muted arrow labeled 'read left to right, top to bottom' above four mint-outlined boxes holding 0.9, 0.2, 0.1 and 0.8, each tagged beneath with top-left, top-right, bottom-left, bottom-right; below them the line x = [0.9, 0.2, 0.1, 0.8] and the caption 'one image, one list of four numbers'. Right: a small coordinate plane with axes 'pixel 1 (brightness)' and 'pixel 2 (brightness)', both running 0 to 1, with a single blue dot at 0.9 across and 0.2 up, dashed gray guide lines dropping to each axis, and a blue label reading (0.9, 0.2). Beneath: 'the first two numbers, as one point'.
Picture, list, point: one object, written three ways. The right panel plots only the first two of the four numbers, because a page is flat. The real point uses all four coordinates at once, and the arithmetic is identical.

Real images are bigger. A modest square image is 512 pixels across and 512 pixels down, and each pixel in color carries three numbers: how much red, how much green, how much blue. There are three because the human eye has three kinds of color-sensing cell in it, so three numbers at every dot reproduce anything you can see. A screen works the same way, with three tiny lamps at every dot. Count them:

$$512 \times 512 = 262{,}144 \qquad 262{,}144 \times 3 = 786{,}432$$

In words: the grid holds 262,144 pixels, and each one needs three numbers for its color, so the whole image is 786,432 numbers.

So one photograph of one apple is one list of 786,432 numbers, which is one point in a space with 786,432 dimensions. Mathematicians write "the space of all lists of $d$ numbers" as $\mathbb{R}^d$, so our apple is a point in $\mathbb{R}^{786{,}432}$. Don't try to visualize that. Nobody can. What this book does instead, and what every diagram you will see of this subject does, is draw two of those axes and quietly ignore the other 786,430. The picture is a cartoon. The reasoning behind it holds.

How far apart are two images?

Once images are points, "these two pictures look alike" stops being a feeling and starts being a measurement. Similar images sit near each other, different images sit far apart. And you already know how to compute distance between points. It's the Pythagorean theorem, in as many dimensions as you like.

Worked example — the distance between two points

Take two two-number lists, small enough to check by hand: $\mathbf{a} = [3,\, 4]$ and $\mathbf{b} = [1,\, 1]$. Subtract them coordinate by coordinate. First coordinate: $3 - 1 = 2$. Second coordinate: $4 - 1 = 3$. Square each difference: $2^2 = 4$ and $3^2 = 9$. Add them: $4 + 9 = 13$. Take the square root. The length of the gap, written $\|\mathbf{a} - \mathbf{b}\|$ and read "the length of a minus b", is

$$\|\mathbf{a} - \mathbf{b}\| = \sqrt{(3-1)^2 + (4-1)^2} = \sqrt{4 + 9} = \sqrt{13} \approx 3.606$$

In words: walk 2 across and 3 up, and the straight-line distance you have covered is the square root of thirteen, about 3.606.

Check the last step if you like: $3.6^2 = 12.96$, a little under 13, and $3.61^2 = 13.0321$, a little over. So the answer sits between them, at $3.606$. Four significant figures is what this book rounds to mid-derivation, said once here and not repeated.

Nothing about that calculation cared that we used two coordinates. With 786,432 of them you would subtract 786,432 pairs, square 786,432 differences, add them all up, and take one square root. Same formula, run longer. So "similar images are nearby points" is a computable statement, not a figure of speech.

The apple neighborhood

Scatter every real apple photograph you can find into that enormous space, one point each. They do not land at random. They clump into one connected region, because real apples share structure: round-ish outlines, smooth skin, a stem at the top, light falling from somewhere. Any two apple photos are more alike than either is to a photo of a bicycle, and "more alike" now means "closer".

That clump is called the data distribution. Saying that eight times a chapter is tiring, so I'll mostly call it the apple neighborhood. Same thing: the territory where apples live.

A large dark plot with unlabeled axes reading 'image coordinate 1 (of hundreds of thousands)' along the bottom and 'image coordinate 2' up the side. In the upper middle, a faint mint-filled curved band, like a wide smile, holds about 130 small blue dots clustered along it; a mint label with an arrow points at the band reading 'the apple neighborhood'. Two red crosses sit far outside the band, one at the lower left labeled 'static' and one at the lower right labeled 'garbage'. A muted note in the top-right corner reads 'every possible image lives somewhere on this plane'. A legend at the bottom reads 'one real apple photo = one point'.
Generating, defined precisely. Every blue dot is one real apple photograph. The mint region is where apples live; the two red crosses are points in the same space that decode to nothing anybody would call a picture. The whole task of this book is to land a new point inside the mint.

That gives us a precise definition of the job. Generating a new apple means finding a fresh point inside the apple neighborhood. Land inside it and you get a believable apple. Land outside it and you get a wash of noise or a smear. There is no third outcome, and there is nothing else to the problem.

Why a lucky guess never works

Picking a point inside the apple neighborhood by guessing is hopeless, and the reason dictates everything the rest of the book does.

The neighborhood is a small, complicated region floating in a space of hundreds of thousands of dimensions. High-dimensional spaces are far emptier than our intuition allows. Take a $d$-dimensional cube and ask what fraction of it lies in the middle half of every axis at once. Along one axis, the middle half is a fraction $1/2$. The axes are independent, so along two axes at once it is $\tfrac12 \times \tfrac12 = \tfrac14$, along three it is $\tfrac12\times\tfrac12\times\tfrac12 = \tfrac18$, and along $d$ of them:

$$\left(\tfrac{1}{2}\right)^{d}$$

In words: the share of the cube that is central in all $d$ directions at once is one half, multiplied by itself $d$ times.

Put a number in. At $d = 10$ that fraction is $1/2^{10}$, and $2^{10} = 1{,}024$, so about one part in a thousand. At $d = 20$ it is $1/2^{20}$, and $2^{20} = 1{,}024 \times 1{,}024 = 1{,}048{,}576$, about one part in a million. That is at twenty dimensions. We have 786,432 of them, and the pattern only steepens.

Picking a good apple point by luck is a blindfolded pin drop into a stadium, hoping to hit one particular seat, and that flatters the problem. A big stadium holds fifty thousand seats, so a blind drop finds your seat about one time in fifty thousand. Those are better odds than the twenty-dimensional cube we just computed, and far better than the real thing. Random guessing here is not a slow method. It is no method at all.

A path instead of a jump

So we stop trying to jump. The trick the whole field is built on is to move in small steps instead.

We teach a model to walk. Take a real apple — a point sitting comfortably inside the neighborhood — and add a little bit of random noise to every one of its numbers. The point shifts slightly. The picture looks like an apple with some grain on it. Do it again. And again, hundreds of times, each time nudging the point a little further out, until the apple is buried in static and the point is nowhere near the neighborhood. That march outward has a name we will use for the rest of the book: the forward process, which means adding noise on purpose.

The same dark plot as before, with the faint mint band of the apple neighborhood holding its blue dots in the upper middle. Starting from one large mint dot inside the band, labeled 'a real apple', a chain of eight mint dots steps down and to the left, each linked to the next by a small muted gray arrow; the dots shrink slightly as they go. The last one sits alone in the lower left, labeled 'pure static'. A muted label to the right of the chain reads 'forward: add a little noise, eight small steps'. Sweeping up the left-hand side, a long curved mint arrow runs from beside the static point back up to beside the apple, labeled 'reverse: the same path, walked backward'.
The step that makes the problem solvable. Gray arrows going out are the forward process: cheap, mechanical, and something we can run a million times before breakfast. The mint arrow coming back is the reverse process. That one has to be learned, and it is the subject of Chapters 3 and 5.

Why would destroying our data help? Because it hands us a path. We now know a route from inside the neighborhood all the way out into the randomness, and we know it step by step, because we built it ourselves one small nudge at a time. Every intermediate point along that route is a fact we can write down.

A model, in this book, means a function with a great many adjustable numbers inside, tuned until the function does what we want. That is the whole definition we need here. If you want to see one built from a single unit upward, the AI/ML book does it in the neuron.

Now suppose a model can learn to walk that path backward: shown a slightly noisy apple, it produces a slightly less noisy one, over and over. It no longer needs to start from a real apple. It can start anywhere in the randomness, from a fresh field of static that belongs to no apple at all, take the same kind of small step again and again, and walk into the good neighborhood. That walk back is the reverse process, also called the denoising process, and it is the second arrow on our opening diagram.

That is the answer to "why add noise". It converts one impossible jump into a long series of small, learnable steps. Each step is an easy question: this picture is almost an apple with a bit of grain, so what would it look like with slightly less grain? A few hundred easy questions, answered in a row, accomplish what no single guess could.

One word to take with you: latent

Those points are enormous, 786,432 numbers each, and the reverse walk visits a point hundreds of times on the way in. Doing that arithmetic over and over costs far more than anyone wants to pay.

So in practice these systems do not walk in pixel space at all. They first squeeze each image down into a much smaller summary called a latent, do all their walking in that compact space, and expand the result back into an image only at the end. You don't need the details yet. Chapter 4 is about how that squeeze works and what it costs. For now, take the word with you. That is the "latent" in latent diffusion, the name of the family of models this book is about.

See it move

Watch (17:51): the whole chapter, built from nothing, with every term defined aloud as it arrives. The moment to track is the change from the grid of pixel numbers to a single dot on a plane. The cloud, the neighborhood and the path out to static all depend on believing that one dot is the whole image.

Where you'll meet this

Open any image-generation workflow, ComfyUI or the settings panel of a hosted tool, and the first thing it asks for is a width and a height. That is not a display preference. You are choosing $d$, the number of numbers in the thing you are about to generate, and therefore the space the whole computation happens in. Ask for 512 by 512 in color and you have asked for a point in 786,432 dimensions. Doubling each side quadruples the count, and the cost follows it.

The word latent is written all over those interfaces too: a node that makes an empty one, a wire colored differently from the image wires, a preview that looks like a smudged thumbnail. Every one of those refers to the compact summary we just named, and now you know why it exists. Nobody wants to do the walk in 786,432 dimensions if a much smaller space will do.

There's also a habit worth building now. When a generated image comes out melted or smeared, the useful description isn't "the model made a mistake". It's "the walk ended just outside the neighborhood". That framing will diagnose more problems for you than any list of settings.

What you now know

  • A generative model produces fresh samples of a thing rather than labeling existing ones, and it learns from many varied examples — which is why our nine training apples were deliberately all different.
  • An image is a list of numbers and therefore a single point: the 2×2 grid flattens to $\mathbf{x}_0 = [0.9,\, 0.2,\, 0.1,\, 0.8]$, and a 512×512 color photo is $512 \times 512 \times 3 = 786{,}432$ numbers, one point in $\mathbb{R}^{786{,}432}$.
  • Distance between images is ordinary distance between points: $\|\mathbf{a} - \mathbf{b}\| = \sqrt{(3-1)^2 + (4-1)^2} = \sqrt{13} \approx 3.606$, so "similar images are nearby" is a computable claim rather than a metaphor.
  • Real apples clump into the data distribution — the apple neighborhood — and generating means landing a fresh point inside it.
  • Guessing that point is hopeless: the middle-half fraction $(1/2)^{d}$ is already about one in $1{,}048{,}576$ at just $d = 20$, and we have 786,432 dimensions. A blindfolded pin drop into a stadium has better odds.
  • Adding noise to a real apple, step by step, traces a path from inside the neighborhood out to static — and a model that learns to walk that path backward can start from any random static and stroll in.

Where we're headed. You can now state the problem: land a fresh point inside the apple neighborhood, and do it by walking rather than jumping. What we cannot do yet is take a single one of those steps. We described adding "a little noise" without saying how much, in what pattern, or how to keep the numbers in a sane range as we go, and without those answers there is no path to walk in either direction. The next chapter builds the outward half of the walk, the forward process, and pins down each of those quantities.