4.5.15 · D1Generative Models

Foundations — Latent diffusion (Stable Diffusion)

2,081 words9 min readBack to topic

Before you can read the parent note, you need to own every symbol it throws at you. Below, each symbol is introduced only after the one it depends on. Nothing is used before it is built.


1. Pixels, images, and the number

Look at the figure: a 4×4 image is really numbers. A real 512×512 image is numbers.

  • Plain words: is "the whole image, written as one long list of brightness numbers."
  • Picture: a stack of three grids (Red grid, Green grid, Blue grid).
  • Why the topic needs it: the entire goal is to produce an — a valid image — from noise.

Why this notation and not "a picture"? Because the network only ever sees numbers. Writing tells us exactly how many numbers — and that count is the whole efficiency story of Latent diffusion (Stable Diffusion).


2. Dimension, and why "big" is expensive

  • Picture: imagine each number as one lever on a giant control panel. Dimension = number of levers you must set.
  • Why the topic needs it: the parent's headline "98% dimension reduction" is meaningless until you feel that dimension = money and time.

3. The latent — a compressed sketchpad

  • Plain words: is the small drawing; is the big finished painting.
  • Picture: a big 512×512 canvas shrinking down to a 64×64 pad of 4 abstract channels (not red/green/blue — learned features).
  • Why the topic needs it: all the expensive denoising happens on , not .

The symbol means "much less than." We use it (not just ) to stress the gap is huge — that gap is where the speedup lives.


4. The autoencoder: and

To move between the big painting and the small sketch , we need two machines.

  • Picture: a funnel narrowing (encode) then a funnel widening (decode), .
  • Why we need both: we live in pixel-world (the prompt-giver wants a picture) but work in latent-world. gets us in, gets us out.

Why calligraphic letters ? Just a convention that says "this is a whole neural network, not a single number." See Variational Autoencoders (VAE) for why the "V" (variational) version is required — it keeps -space smooth with no holes.


5. Gaussian noise and

  • Picture: a bell curve, most darts landing near the center.
  • Why the topic needs it: diffusion is entirely about noise — adding it (forward) and predicting it to remove it (reverse). If you don't know what means, no formula in the parent parses.

6. The noisy latent , timestep , and the schedule

The bar over means "cumulative product from step 1 to ": . The symbol is a repeated multiply (like but with instead of ), and is how much noise we inject at each single step. See Denoising Diffusion Probabilistic Models (DDPM) — latent diffusion reuses this exact schedule.

  • Why the topic needs it: this is the training data generator. To teach the network to remove noise, we must first add known amounts of it.

7. The noise predictor and the U-Net

  • Picture: a machine that looks at static-covered art and points at exactly which speckles are noise.
  • Why a U-Net specifically? It sees the latent at many zoom levels at once (coarse shapes + fine texture), which is exactly what denoising needs. Details in U-Net Architecture.

8. The text hint and cross-attention

  • Picture: each patch of the sketch raising its hand and asking the words "which of you describes me?"
  • Why the topic needs it: without , the U-Net denoises into some image; with , it denoises into your image. This is how text controls the picture — see also Classifier-Free Guidance.

9. Sampling: turning noise back into a picture

  • (sigma) = how much fresh randomness we re-inject each step (controls variety). Setting it to zero gives the deterministic DDIM Sampling variant.
  • Why loop instead of one jump? Each step is a small, easy correction; asking the network to leap from full static to a clean image in one go is too hard.

Prerequisite map

Image x as grid of RGB numbers

Dimension equals cost

Latent z the small sketchpad

Encoder E and Decoder D

Gaussian noise epsilon

Noisy latent z_t and schedule

U-Net noise predictor

Text vector c from CLIP

Cross attention lookup

Reverse sampling loop

Latent Diffusion Stable Diffusion


Equipment checklist

Test yourself — cover the right side and answer aloud.

What does mean in plain words?
An image written as pixels, each holding 3 numbers (R, G, B).
Why is "dimension" the same thing as "cost"?
Dimension = how many numbers; every number costs compute and memory each step, done hundreds of times.
What is the latent , and how big is it in Stable Diffusion?
A compressed sketch of the image; instead of .
What do and do?
encodes image → latent; decodes latent → image (, the approximate reconstruction).
Read aloud.
"Epsilon is fresh Gaussian noise, mean zero, spread one, each entry independent."
Why do and appear in ?
They trade off signal vs noise while keeping the latent's statistical size fixed (, ).
What does output?
The network's guess of the noise added to , given timestep and text hint .
What role does play, and where does it come from?
The prompt as numbers from CLIP; it steers denoising via cross-attention so the image matches your words.
Why sample in a loop instead of one jump?
Each small denoising step is easy and accurate; one giant leap from static to image is too hard for the network.