U1.2 Denoising: How Do We Learn a Reverse Step?
Builds on7 notes
- L0.1One Degree or Ten: A Loss Function Declares What Matters
- L0.0How an Agent Prices a House: Learning Rules from Examples
- M1.2Which Temperature Should We Forecast? MSE Selects the Conditional Mean
- M1.3A Positive Test: Bayes' Rule and the Posterior
- M1.0Two Scales: Linear Combinations of Gaussians
- M5.1The Cost of a Wrong Probability Table: KL Divergence and Cross-Entropy
- L5.1What can we optimize when the required marginal is intractable?
How can we sample a reverse step?
We can move forward and sample any directly from . Now, given , we want a draw from .
ReviewWhy a distribution rather than one answer?
The reverse conditional describes the density of possible previous states given the present .
On our trip to Pingtung, the preceding stop could have been Kaohsiung on the west coast or Taitung on the east coast. A conditional distribution assigns probabilities to both possibilities.
Corruption loses information: many preceding states can lead to the same present state. A distribution represents that uncertainty. How we later use this information, through stochastic or deterministic generation, is developed in U1.4.
The forward Gaussian perturbation leaves a range of plausible preceding states. We need their conditional density.
DiscussionQ1
Why not invert the corruption formula? We know
so perhaps we can draw a fresh and solve
After all, the noise was random.
Why does this fail?
Show the reasoning
Noise is independent when we construct the forward step, but not after conditioning on its result.
Forward construction first fixes and independently draws . The observed depends on that particular hidden noise, so observing gives information about .
Their covariance makes the dependence explicit. Since and are independent,
Nonzero covariance rules out independence. Fresh independent noise cannot replace the original noise after observing .
The marginal law of remains standard Gaussian. Its conditional law given is different, and that is the law inversion would require.
A shuffled deck gives the same intuition. Although the shuffle was random, its observed result constrains what that particular shuffle did.
Applying an unrelated random shuffle backward does not undo the original one. Likewise, we cannot independently redraw the hidden .
Could we calculate the reverse conditional directly instead?
We know the forward transition, so Bayes’ rule suggests
The forward factor is known. But and are noisy-data marginal densities, averaging over all possible clean data. They depend on the unknown . This is an intractable expression: we can write it, but cannot directly evaluate it.
If we cannot calculate it, can we learn it?
We did not expect every quantity to be analytically available. Otherwise there would be little need for learning.
Let a network parameterize . Our goal is to adjust until this conditional distribution approximates the true reverse law.
Then we would no longer need to calculate the true conditional explicitly.
The question changes from
How do we calculate this distribution?
to
What learning problem would teach a network this distribution?
We first define closeness using KL divergence (M5.1), averaging over the random input :
We have an objective, but its target is still intractable. We cannot yet evaluate the loss or its gradient.
DiscussionQ2
What information do we actually have? What did the forward process give us?
Training draws , , and , then constructs . We know the full tuple, rather than only .
Which extra information might make the target, or an equivalent loss, tractable?
Show the reasoning
。
The difficult marginals average over all possible clean origins. During training, however, we know the particular that produced this input.
Let us condition on that first.
Training gives us one extra piece of information
Recall how the noisy input was constructed.
Training begins with clean data and adds noise, so its origin is known. Generation only has the current state, and cannot use this extra information.
Would knowing the clean origin simplify the target? Instead of the first conditional, consider the second:
The second is tractable. This suggests the training objective
The target sees , but the learned model does not.
That restriction is necessary: generation has no clean endpoint available. Training may use extra information to construct a target, while the predictor still only receives and .
Are we still learning the original reverse conditional despite this asymmetry?
Yes: this change of objective is an exact identity up to a constant.
For fixed , many clean images could have produced it. The model cannot distinguish their identities, so it must fit their conditional distributions collectively, weighted by how likely each origin is given .
Their mixture is
Thus fitting all the tractable conditional targets averages them into the intractable marginal target.
A squared-error analogy helps. If , fitting all three labels has the same optimum as fitting their mean, because completing the square gives
This suggests the corresponding KL identity:
does not depend on . In an unrestricted conditional family, the optimum is the mixture above, namely .
We have exchanged an intractable objective for a tractable one with the same minimizers, without directly evaluating the marginal target.
Try itDerive the parameter-independent difference between the objectives
We want to show that conditioning the training target on preserves the original optimization problem.
Fix and consider
Expand the KL definition:
The first term is
It contains no and remains constant after averaging over clean and noisy states.
Only the second term affects learning:
Average over clean origins compatible with :
The model log density does not depend on , so we can average the target density first:
The bracketed expression is
Marginalizing over possible clean origins, weighted by their posterior probabilities, gives
The second term therefore becomes
This is the cross-entropy of the marginal reverse law and the model.
Expanding the original KL produces exactly the same parameter-dependent cross-entropy. Its remaining entropy term is also independent of .
The objectives therefore differ only by a constant:
With sufficient model expressiveness, the optimum is
Extra training information thus teaches the reverse distribution we originally wanted.
We call this recurring construction the conditional trick: make a marginal target tractable by conditioning, and let the loss perform the remaining averaging. Lai and colleagues [2] organize its diffusion variants. This note uses KL; U1.3 uses MSE, and U2 applies it to velocity.
Calculate the conditional posterior
Now derive the tractable target using Bayes’ rule:
The second equality uses the Markov property: the next forward step only depends on the current state. All three factors are known forward-process Gaussian densities.
The first is a transition; the other two use the direct-sampling formula from U1.1:
These are products and ratios of densities, not random variables. Gaussian exponents are quadratic; combining them and completing the square gives another Gaussian.
Does the resulting posterior variance depend on ?
Try itComplete the square to obtain the posterior mean and variance
Only varies; and are fixed. The denominator is constant with respect to , so consider the product in the numerator:
Collect the quadratic coefficient:
Writing the linear term as gives
The exponent becomes plus a constant. Comparing with a Gaussian gives variance and mean .
Simplify using and :
Thus . Multiplying this by gives the two mean coefficients below.
Substitution yields
and
The mean is a schedule-dependent linear combination of and . Its coefficients need not sum to one. The variance depends on the schedule alone, not on either observed value.
Training DDPM
We can now evaluate the training target:
Only the mean depends on the image values. The model lacks , so keep the variance and mean formula, replacing the clean image with :
The network receives only information available during generation: the present state and timestep. U1.4 examines the cost of this Gaussian assumption.
With equal fixed covariances, KL reduces to a distance between means:
Equal Gaussian normalizers cancel. Expanding the quadratic forms leaves precisely the squared difference of the means.
The posterior mean is affine in , with the displayed schedule coefficient. Consequently its error is proportional to clean-image prediction error:
The full objective becomes weighted squared error:
The input is sampled directly from . We have arrived at regression, without an adversary or an intractable normalizing constant.
But this raises a familiar concern:
Did we not just reject ?
Why does it work here?
DiscussionQ3
In U1.0, independent-pair learned one mean image. This is also squared error against real clean data.
Why does it avoid the same problem?
Show the reasoning
The difference is pairing.
Previously, noise and data were independent, so the optimum was a constant. Now the forward process couples to . The optimum is a conditional expectation (M1.2):
This is a function of the observed . At low noise it is close to the original image; at high noise many origins are plausible, so their weighted average is appropriately blurry.
The old optimum was constant; this optimum depends on the observed state.
Think of reading an eye-chart symbol. When it is clear, its orientation is obvious. When it is almost unreadable, uncertainty over several orientations is appropriate. The information in the input determines the conditional average.
A positive weight depends only on time, so it does not change the unrestricted optimum at each fixed noise level.
Substituting the optimal predictor into the reverse mean gives
This is the true reverse conditional’s mean. In our Gaussian approximation, the schedule specifies spread and the learned conditional clean mean specifies the center. It need not equal the true reverse conditional’s variance.
We have used the conditional-mean property here. Its proof and implications are developed in U1.3.

Figure: one noisy state, several clean origins. A broad posterior produces a blurry conditional mean. That blur can be the correct regression answer.
Watch a point being denoised
Interactive demo. Choose and vary the noise level. Point sizes encode posterior weights proportional to . The arrow points to the conditional mean. At high noise, many candidates contribute.
How do we generate after training?
Given a trained network and current state , we want to generate .
Our reverse model is
We parameterize it as a Gaussian, substitute the predicted clean image into the posterior mean, and sample:
This completes one reverse step.
Start from
and repeat:
The final state is a generated sample.
We now have both a training procedure and a generation procedure.
Why should regression improve generation?
Our practical objective is regression. How does it connect to the distribution of generated data?
We can follow three steps.
First, start with likelihood. Marginalizing the latent path makes difficult to evaluate. Introducing the forward path and applying Jensen’s inequality gives
This supplies an upper bound on negative log-likelihood, corresponding to the negative ELBO; see What can we optimize when the required marginal is intractable?.
Second, compare distributions over complete paths. Averaging over real data yields
We are fitting the model’s reverse-path law to the forward-path law induced by data.
Third, factor the path-level KL through the Markov structure. Its parameter-dependent transition terms are
These are the reverse-step objectives we converted into regression. The terminal prior term is fixed when the prior is fixed; the boundary reconstruction term is handled separately.
The connection is therefore
Regression is thus connected to generative likelihood rather than chosen arbitrarily.
This does not imply exact reverse transitions: our single-Gaussian model family generally cannot express the true reverse conditional.
How accurate is this approximation? Must sampling add noise? What changes as timesteps become smaller?
We will discuss these questions in U1.4.
A reverse step need not predict clean data directly
Given , knowing either clean data or accumulated noise determines the other:
A network may predict noise and convert it to a clean estimate. This choice of output representation is its parametrization.
Three common choices are clean-data prediction, noise prediction, and prediction.
Clean-data prediction outputs , as in the derivation above.
Noise prediction, used in DDPM [1], estimates the accumulated noise:
prediction, introduced by Salimans and Ho [3], writes the coefficients as cosine and sine and defines
In the coefficient plane, is perpendicular to the direction. It approaches noise at one end and negative clean data at the other. This useful endpoint behavior returns in U5.1.
NotationIn what sense is v perpendicular?
Since , write the coefficients as and :
These form orthogonal coordinates in the two-dimensional coefficient space of clean data and noise; this does not assert that the realized image vectors are perpendicular. The expression is the derivative of with respect to .
At nondegenerate noise levels, the three predictions are related by time-dependent affine transformations. A trained output can be converted algebraically without retraining.
Does training each representation with the same-looking MSE produce the same model?
Equivalent representations, different training objectives
Suppose each representation uses MSE:
Converting errors back to the same quantity introduces noise-level-dependent weights.
Substitute the clean/noise conversion:
The derived weighted objective becomes, in noise coordinates,
Thus interconvertible outputs do not imply identical unweighted training objectives.
With unrestricted functions and positive weights, the pointwise optimal predictors correspond under conversion. Finite model capacity and training time make the relative emphasis across noise levels matter:
Different parametrizations prioritize errors at different noise levels.
DDPM makes an additional practical choice.
It discards the derived noise-space weighting and uses uniform noise MSE:
This separates two design decisions:
The forward process determines the noisy training data.
Loss weighting determines the relative training emphasis.
Changing weights leaves the ideal predictor at each time unchanged, but changes practical optimization. The particular likelihood bound derived above no longer follows unchanged. Kingma and Gao [4] study the broader relationship between diffusion objectives and ELBOs. We return to this distinction when comparing diffusion with Flow Matching.
The core DDPM training loop
repeat
x0 ← a batch of training data
t ← Uniform{1,…,T}
ε ← N(0, I)
xt ← √ᾱ_t · x0 + √(1-ᾱ_t) · ε
loss ← ‖ε_θ(xt, t) − ε‖²
take a gradient step
Implementation still requires batch size, , schedule, architecture, and optimizer choices, but this is the central loop.
U1.5 implements it. Its loss need not approach zero; U1.3 explains why a positive residual can be unavoidable.
Check your understanding
References
- Ho, J., Jain, A., Abbeel, P. Denoising Diffusion Probabilistic Models. NeurIPS 2020.
- Lai, C.-H., Song, Y., Kim, D., Mitsufuji, Y., Ermon, S. The Principles of Diffusion Models. 2025, Section 2.2.
- Salimans, T., Ho, J. Progressive Distillation for Fast Sampling of Diffusion Models. ICLR 2022.
- Kingma, D. P., Gao, R. Understanding Diffusion Objectives as the ELBO with Simple Data Augmentation. NeurIPS 2023.