Take a clean image and add a little noise. Add a little more. Keep going for a few hundred steps and you end up with static, an image indistinguishable from random noise. That destruction is easy and needs no learning at all; it is just repeated addition of noise. The insight behind diffusion models is that if a network could learn to undo one step of that process, to look at a slightly noisy image and predict the noise that was added, then you could run the whole thing backward. Start from pure noise, subtract the predicted noise step by step, and a coherent image emerges that was never in the training set.

The idea

A diffusion model, made practical by Ho and colleagues in 2020 (the DDPM paper), defines a fixed forward process that gradually corrupts data into noise over steps, then learns the reverse. A network is trained to predict the noise present in a partially corrupted image. To generate, sample pure noise and apply the learned denoiser repeatedly, walking the chain backward from noise to a clean sample. The name comes from modeling a diffusion process in thermodynamics.

The Forward Process: Scheduled Destruction

The forward process is a fixed recipe, not something the model learns. Starting from a clean image , each step produces a slightly noisier version by mixing in a bit of Gaussian noise:

Here is a small variance that controls how much noise enters at step , set by a schedule chosen ahead of time. Each step nudges the image toward randomness and scales down what remains of the signal. Repeat for steps and is essentially a sample of pure noise, all trace of the original image gone. Because every step just adds known Gaussian noise, there is no learning here. The forward process exists only to manufacture training pairs: a noisy image and the exact noise that was put into it.

The forward process adds Gaussian noise step by step from a clean image to pure noise; the learned reverse process denoises one step at a time back to a clean image

The Reverse Process: Learned Denoising

Undoing the noise is where the network comes in. The model learns the reverse transition : given a noisy image at step , recover a cleaner image at step . In practice the network is trained to predict the noise that was added at that step, which is a plain regression target trained with gradient-descent. The architecture that carries this is typically a U-Net, an encoder-decoder with skip connections (the same shape used in image segmentation), which takes a noisy image and the step index and outputs a noise estimate the same size as the image.

The training loop is a direct consequence of the setup. Pick a training image, pick a random step , run the forward process to noise it up to while keeping the noise you added, and ask the network to predict that noise from . The loss is the error between the predicted noise and the actual noise. Because the forward process hands you a perfect target for free, the whole thing trains without labels, a form of unsupervised-learning on the data itself.

Generation: Walking the Chain Backward

Sampling is the reverse process run end to end.

  1. Sample from a standard Gaussian , pure noise.
  2. Feed the current image and step to the network to predict the noise in it.
  3. Use that predicted noise to take one small step toward a cleaner image, .
  4. Repeat, stepping down until you reach , a finished image.

Nothing about came from the training set, so the output is genuinely new. This is what puts diffusion in the same family as the variational autoencoder and the GAN: all three sample new data by pushing random noise through a learned map. The routes differ. A VAE decodes a single draw from an organized latent prior, a GAN generates in one forward pass judged by an adversary, and a diffusion model reaches the image through many small denoising steps. That iterative refinement is slower to sample but tends to train stably and produce high-fidelity, diverse output, sidestepping the mode collapse that plagues GANs.

Example

Stable Diffusion generates images from text prompts and runs on consumer hardware with slightly fewer than parameters. It adds two tricks to the basic recipe. It runs the diffusion process in a compressed latent space rather than on raw pixels, so an autoencoder shrinks the image first and expands the result at the end, which is far cheaper. And it conditions the denoising U-Net on the text prompt through cross-attention, so the noise the network predicts depends on the words. Prompt it with “a photograph of an astronaut riding a horse” and the backward walk from noise lands on exactly that, an image that has never existed.

Sources