Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Diffusion Models: Forward Corruption and Learned Reverse Processes

Hello, and welcome to the first lesson in Diffusion Models in ML. This first module builds the basic construction that everything else in the course relies on: a known process that progressively corrupts data, and a learned process that turns noise back into data.

By the end of this lesson, you should be able to write down both probability models, explain why one is fixed while the other must be learned, and describe exactly what happens when a diffusion model generates an image. We will intentionally postpone the training-loss derivation: the immediate task is to understand the two chains and their roles.


The central idea: make generation a sequence of manageable denoising decisions

A generative model should produce new samples that resemble the training data: for example, plausible faces, molecules, audio clips, or images. Diffusion models do this by beginning with a simple distribution we can sample from easily, usually standard Gaussian noise, and transforming it into data through many small stochastic denoising steps.

The construction is easiest to understand in the opposite direction first:

  1. Take a real data example , such as a clean image.
  2. Add a small amount of random Gaussian noise.
  3. Repeat the corruption many times until the result is nearly indistinguishable from Gaussian noise.
  4. Learn to run a corresponding process in reverse, moving from back toward a clean sample.

The key asymmetry is deliberate:

  • Forward corruption is designed by us and entirely known.
  • Reverse denoising depends on the unknown data distribution, so its transitions must be learned from examples.

Watch the following short segments from Ari Seff’s What are Diffusion Models? for a visual first pass through this construction.

What are Diffusion Models?

In What are Diffusion Models? by Ari Seff, the opening segments build the visual intuition before introducing the probability notation. Watch them now to connect the equations in this lesson to the concrete task of turning an image into static and static back into an image.

Watch the core idea for the overall corruption-and-recovery picture. Then watch the forward chain, focusing on why each state depends only on the preceding one and how a noise schedule controls corruption. Finally, watch the learned reverse, noting that the network receives both the noisy sample and its timestep.

A Markov chain is central here. It means the next state depends on the present state, rather than needing the complete past history. For the forward chain, once is known, the earlier states are irrelevant for producing .

A diffusion model consists of a known forward process, shown from the clean image \(\mathbf{x}_0\) at right to noisy \(\mathbf{x}_T\) at left, and a learned reverse process that starts from noise and samples toward a clean image. The figure highlights that the unconditional reverse conditional is not directly known.

The figure is laid out with clean data on the right and noise on the left, so its visual direction is opposite the usual timestep order. Mathematically, the forward process still runs from to ; sampling runs from down to .


The fixed forward diffusion process

Let denote a data vector. For an RGB image, it might have shape , but the mathematics treats it as one high-dimensional vector. Diffusion creates noisy versions

Choose a variance schedule:

where each is small and positive. The schedule specifies how much fresh noise is injected at each step. Define

The one-step forward transition is a Gaussian:

Equivalently, we can sample this transition as

Each step has two effects:

  • It slightly shrinks the previous sample by .
  • It adds independent Gaussian noise with variance .

The full forward chain is therefore

This is called fixed because it contains no learned parameters . Once you select and the schedule , you can generate a noisy version of any training image immediately.

A subtle but important point: the forward process is not a generator. It does not learn, identify objects, or create new semantic content. Its job is to convert a complicated data distribution into a simple terminal distribution that is approximately

The ability to sample standard Gaussian noise is what makes the eventual generative procedure practical.

Read the two opening subsections of Lilian Weng’s What are Diffusion Models? to reinforce the formal definition and see the forward and reverse chains placed side by side.

What are Diffusion Models? | Lil'Log

Read Lilian Weng’s Lil'Log overview for a compact account of the forward Gaussian process and the reason a learned reverse process is needed.

In the subsection “Forward diffusion process,” read the forward construction, including the displayed one-step Gaussian transition and product over timesteps. Focus on what is specified by the schedule and why the full sequence is Markov. Then, in “Reverse diffusion process,” read the reverse problem. Stop after the sentence explaining that a model must approximate these reverse conditionals; the posterior derivation below it is the subject of a later module.

It is common to use for both the data-associated forward process and related distributions. Keep the roles straight:

  • is the chosen corruption rule.
  • is the true reverse conditional induced by the data distribution and corruption rule.
  • is the learned approximation used at generation time.

Why reversing the process is difficult

It may seem that we could simply “subtract the noise” at each step. But the noisy observation generally does not tell us which exact clean image produced it.

Imagine that a heavily corrupted image contains a vague light-colored oval in the center. It might have come from a face, an animal, a bowl, or merely an abstract image. The correct reverse distribution must represent what is plausible under the training data, not just remove pixelwise noise.

Formally, the object we would like to know is

Bayes’ rule suggests that it depends on

The transition is known, because we designed it. The problem lies in the marginal distributions and : they reflect the full, complex distribution of real images after noise has been added. We only have a finite dataset of samples from that distribution, not a simple analytical expression for it.

There is a related conditional distribution,

that becomes tractable because it is allowed to use the original clean sample . During training, that clean image is available. During generation, it is exactly what we do not have. The next module will derive this useful training-time posterior carefully.

For now, the essential conclusion is: knowing how to corrupt data does not automatically give us a usable reverse process. We must learn one.


The learned reverse Markov chain

Diffusion models define a parameterized reverse-time probability model:

Its initial distribution is simple:

For a standard DDPM, each learned reverse transition is modeled as a Gaussian:

Here, denotes the parameters of a neural network, typically a U-Net for images. Given a noisy image and a timestep , the network outputs information that determines a distribution for the slightly cleaner sample .

The timestep is necessary. A pattern that looks like weak texture at an early timestep may be mostly random noise at a late timestep. The model needs to know the noise level in order to apply the appropriate denoising behavior.

Component Forward process Reverse process
Purpose Corrupt real data Generate or denoise samples
Direction in timestep through down through
Parameters Fixed schedule Learned network parameters
Starting point A real datum Gaussian noise
One-step rule Known Gaussian Learned Gaussian approximation
Used during generation? No Yes

Why use a Gaussian for the reverse step if images are highly complex? The full image distribution is indeed complex and can be multimodal. But the model does not try to transform noise into an image in one Gaussian step. Instead, it composes many small, time-conditioned transitions. A simple local conditional at each step can produce a highly non-Gaussian distribution over final images.

Small forward noise steps also make this modeling choice more reasonable: locally, reversing a tiny Gaussian perturbation can be well approximated by a Gaussian transition whose mean depends on the current noisy sample and the noise level.


Sampling: how a new image is generated

After training, generation follows the learned reverse chain.

  1. Draw an initial noise tensor:

  2. At timestep , feed and to the denoising network.

  3. Use its output to define and sample from

  4. Repeat at , each time obtaining a somewhat cleaner sample.

  5. Return as the generated image.

The word sample matters. The reverse chain defines distributions, not merely a deterministic editing procedure. Reverse-time randomness allows the model to represent variation among plausible outputs. Later, we will see samplers that intentionally reduce or remove some of this randomness for speed.

At training time, the direction is different:

  1. Draw a clean training sample .
  2. Corrupt it with the fixed forward process to obtain a noisy .
  3. Adjust so that the learned reverse transition is consistent with how the forward process created that noisy sample.

The precise objective used to make “consistent” mathematically meaningful is the variational diffusion objective, which begins in the next module.


A compact formulation checklist

A correct formulation of a basic discrete diffusion generative model should include all five items below:

  1. Data variable: is a sample from the unknown data distribution.

  2. Forward Markov chain:

  3. Known noise schedule: is fixed before training in the basic DDPM construction.

  4. Reverse Markov chain:

  5. Learned reverse conditional:

The forward chain gives the training problem its structure; the learned reverse chain is the actual generative model.


Key takeaways

A diffusion model pairs two Markov chains over variables of the same dimensionality as the data:

  • The forward process is a fixed, known Gaussian corruption process governed by a noise schedule.
  • Repeated forward corruption transforms structured data into a distribution close to standard Gaussian noise.
  • The true unconditional reverse conditional depends on the unknown data distribution and cannot be directly computed from the forward transition alone.
  • A neural network parameterizes a learned reverse Markov chain, usually with Gaussian transitions conditioned on the noisy sample and timestep.
  • Generation begins from Gaussian noise and samples repeatedly from learned reverse transitions until it reaches .

Next, we will derive a crucial shortcut: the closed-form distribution of conditioned directly on . That result makes it possible to add the appropriate amount of noise at any timestep without simulating every preceding forward step.

Can't find a good explanation? Sign up and we'll make it for you

Sign up