DEV Community

zeromathai
zeromathai

Posted on Originally published at zeromathai.com

Diffusion Models: From Noise Corruption to Reverse Generation

A diffusion model does not try to solve generation from a complex data distribution in one step.

Instead, it defines a Forward Diffusion Process that gradually corrupts real data with Gaussian noise, then learns a Reverse Diffusion Process that moves in the opposite direction, from noise back toward data.

The core idea is straightforward:

data
  |
  | add Gaussian noise step by step
  v
intermediate noisy states
  |
  v
Gaussian noise

Gaussian noise
  |
  | learned reverse transitions
  v
less noisy states
  |
  v
generated data
Enter fullscreen mode Exit fullscreen mode

Define a manageable path from data to noise, then learn how to travel back along that path.

Turn a Hard Generation Problem Into Many Smaller Steps

High-dimensional data such as images follows a complicated distribution. Diffusion Models avoid tackling that generation problem directly by introducing a gradual corruption process.

Start with a real sample x0x_0 . As Gaussian noise is added over multiple steps, we obtain

x0x1x2xT x_0 \rightarrow x_1 \rightarrow x_2 \rightarrow \cdots \rightarrow x_T

As tt increases, the structure of the original sample becomes weaker while noise becomes more dominant. In the theoretical limit of an infinitely long process,

T,xTN(0,I) T \rightarrow \infty,\qquad x_T \sim \mathcal{N}(0,I)

the final state approaches an isotropic Gaussian distribution with mean zero and identity covariance.

This changes the generation problem in an important way. The original data distribution may be highly complex, while sampling from a Gaussian distribution is straightforward. Once the path from data to noise has been defined, generation becomes the problem of learning how to move from that Gaussian endpoint back toward the data distribution.

Forward Diffusion: Gradually Corrupt the Data

The Forward Diffusion Process begins with a data sample x0x_0 and progressively adds Gaussian noise.

Each step is a stochastic transition. The transition from xt1x_{t-1} to xtx_t can be written as

q(xtxt1) q(x_t \mid x_{t-1})

where xt1x_{t-1} is the previous state and xtx_t is the next, noisier state.

Forward diffusion is therefore not one large corruption operation. It is a sequence of probabilistic transitions:

original data
   |
   v
slightly noisy state
   |
   v
more noisy state
   |
   v
...
   |
   v
near-Gaussian noise
Enter fullscreen mode Exit fullscreen mode

As these transitions are repeated, more of the original data structure disappears. With enough steps, the process moves a complicated data sample toward a much simpler noise distribution, which then becomes the starting point for generation.

Reverse Diffusion: Learn the Way Back

Generation follows the opposite direction:

xTxT1x1x0 x_T \rightarrow x_{T-1} \rightarrow \cdots \rightarrow x_1 \rightarrow x_0

But reverse diffusion is not obtained by simply flipping the arrows.

The forward process specifies how noise is added. The reverse distribution required for generation must instead be learned from data.

A single reverse transition is represented as

pθ(xt1xt) p_\theta(x_{t-1} \mid x_t)

Given a noisy state xtx_t , the model learns a probabilistic transition toward the previous, less corrupted state xt1x_{t-1} .

During generation, this learned transition is applied repeatedly across the chain. Sampling starts from Gaussian noise, moves through progressively less noisy states, and eventually reaches a data-like sample.

The model therefore decomposes generation into many smaller probabilistic reverse steps.

Forward and Reverse Processes at a Glance

Process Direction Role
Forward Diffusion x0xTx_0 \rightarrow x_T Gradually corrupt data with Gaussian noise
Reverse Diffusion xTx0x_T \rightarrow x_0 Generate data by reversing the corruption process
Forward transition q(xtxt1)q(x_t \mid x_{t-1}) Defines the next noisy state
Reverse transition pθ(xt1xt)p_\theta(x_{t-1} \mid x_t) Models movement toward a less noisy state

The important distinction is that the forward corruption process is defined, while the reverse process required for generation is learned. Because generation follows that reverse process step by step, diffusion is inherently built around a sequence of stochastic states.

The Score-Based View

The same corruption-and-reversal idea also appears in Score-based Generative Models.

A central quantity is the Score Function:

s(x)=xlogp(x) s(x)=\nabla_x \log p(x)

Here, p(x)p(x) is the probability density and x\nabla_x is the gradient with respect to xx .

The score does not give the density value itself. Instead, it describes the direction in input space in which the log-density increases.

Intuitively, it indicates how a sample should move toward a region of higher data density.

SMLD: Scores Across Multiple Noise Scales

SMLD, or Score Matching with Langevin Dynamics, estimates the Score Function at multiple Noise Scales.

The model learns score information for data corrupted at different levels of noise. During generation, Langevin Dynamics is used while moving from higher Noise Scales toward lower ones.

Conceptually:

high noise
   |
   | Score Function + Langevin Dynamics
   v
lower noise
   |
   | Score Function + Langevin Dynamics
   v
lower noise
   |
   v
data-like sample
Enter fullscreen mode Exit fullscreen mode

At each Noise Scale, the score provides directional information about how the current sample should move relative to the underlying data distribution.

DDPM: Learn Reverse Probabilistic Transitions

A Denoising Diffusion Probabilistic Model (DDPM) approaches the same corruption-and-reversal problem as a sequence of probabilistic steps.

The forward process progressively adds noise to training data. The model then learns a probabilistic process that reverses each corruption step.

The high-level structure is:

Forward:
data -> progressively corrupted states -> noise

Reverse:
noise -> learned probabilistic transitions -> data
Enter fullscreen mode Exit fullscreen mode

The known functional form of the Reverse Distribution makes the learning problem analytically tractable while retaining a flexible generative process.

The central idea is the structured multi-step reversal: DDPM learns how to undo the forward corruption process one probabilistic step at a time.

How SMLD and DDPM Connect

SMLD and DDPM use different training formulations, but they share the same broad structure.

Both progressively corrupt data and learn how to reverse that corruption across multiple Noise Scales. Generation then starts from noise and moves progressively toward the data distribution.

The connection becomes especially clear when considering a continuous state space with continuous tt . In that setting, the DDPM training objective can be interpreted as implicitly computing the score at each Noise Scale.

This is why SMLD and DDPM can be understood within the broader framework of Score-based Generative Models, rather than as completely unrelated generation principles.

What to Look for in an Implementation

The most useful implementation-level distinction is simple: the forward corruption process is defined, the neural network learns the reverse-process information, and generation repeatedly applies the learned reverse transitions.

In short:

data to noise is defined; noise to data is learned.

Why Sampling Speed Is the Main Trade-Off

The same sequential structure that defines diffusion generation also creates its main limitation.

Sampling requires following a long reverse Markov Chain:

xTxT1x1x0 x_T \rightarrow x_{T-1} \rightarrow \cdots \rightarrow x_1 \rightarrow x_0

Because those reverse transitions are applied step by step, a long diffusion chain directly affects sampling speed.

The representative comparison with other major Deep Generative Model families is:

Model Representative limitation
GAN Training can be unstable, and generated diversity can be limited
VAE Sample quality limitations and dependence on a surrogate loss
Flow-based Model Requires specialized architectures for reversible transformations
Diffusion Model Requires sequential sampling through a long diffusion chain

The source also summarizes the quality-diversity-speed trade-off as follows:

Model Quality Diversity Speed
VAE ×
GAN ×
Flow-based Model ×
Diffusion Model ×

This is not an absolute ranking of every implementation. It represents the characteristic trade-off emphasized for each model family.

In this comparison, Diffusion Models are strong in quality and diversity, while their sequential reverse sampling process makes speed the main weakness.

Takeaway

A Diffusion Model is best understood as a learned reversal of progressive noise corruption.

Forward Diffusion defines a stochastic path from real data toward Gaussian noise. Reverse Diffusion learns the probabilistic transitions needed to move back toward data, while Score-based methods describe the same broader problem through the direction in which log-density increases.

SMLD and DDPM differ in formulation, but both fit the same high-level picture: progressively corrupt the data, then learn how to reverse that corruption.

The essential implementation mental model is equally compact:

data to noise is defined; noise to data is learned.

That sequential reverse process is both the core of diffusion-based generation and the source of its sampling-speed trade-off.

Originally published at zeromathai.com.

Original article: https://zeromathai.com/en/diffusion-models-course-en/

Top comments (0)