Hello! Welcome back.
In our last lesson, we completed a deep dive into the DDPM training objective from a variational inference perspective, showing how the seemingly complex Evidence Lower Bound (ELBO) can be simplified into a straightforward mean squared error loss on the predicted noise, . This provided a powerful alternative justification to the score-matching framework we discussed earlier.
Today, we will conclude our first module on diffusion theory by fulfilling our final learning outcome: analyzing and comparing different training objective formulations for diffusion models. We will see that predicting the noise is just one of several valid approaches. We'll explore alternative prediction targets—such as the original data , the score , and a velocity term —and understand their theoretical relationships and practical trade-offs. This knowledge is critical for making informed architectural decisions and debugging model behavior.
1. The Full ELBO vs. The Simplified Loss
Let's start with the conclusion from our last lesson. We found that minimizing the KL divergence between the model's reverse step and the true posterior simplifies to minimizing the squared error between the predicted and true noise:
This is the objective you likely implemented in your prior work. However, remember that this was a simplification. The full loss term derived directly from the ELBO contains a weighting factor that depends on the noise schedule:

This distinction between the full, theoretically-derived ELBO loss and a simplified or re-weighted version is a central theme in modern diffusion models. While the ELBO provides a target for optimizing the data likelihood, practitioners often find that re-weighting the loss at different timesteps can yield better perceptual quality or training stability.
2. A Unified View of Prediction Targets
The choice of weighting is only one part of the story. The other is the choice of what the neural network, , should predict. While predicting the noise is standard for DDPMs, it's not the only option. The model can be parameterized to predict other quantities, and the loss function can be adjusted accordingly.
The paper "Loss Functions in Diffusion Models: A Comparative Study" provides an excellent framework for unifying these different approaches. We'll use it as our guide.
Loss Functions in Diffusion Models: A Comparative Study
To begin, let's read the introduction of the paper 'Loss Functions in Diffusion Models: A Comparative Study'. It introduces the four main prediction targets we'll be discussing: data (x-space), noise (epsilon-space), rate of change (v-space), and score (s-space).
Read Section 3, 'Loss formulations', up to the beginning of Section 3.1. This section introduces the core idea of different prediction targets and distinguishes between the NELBO loss (derived from the ELBO) and the weighted loss (simpler, re-weighted versions).
As the paper outlines, we can re-parameterize our model and reformulate the loss to target different, but related, quantities. Let's look at each one.
A. -space (Noise Prediction)
This is the familiar DDPM approach. The model predicts the noise that was added to to produce .
- Weighted Loss:
- Intuition: The network learns to "peel off" a layer of noise at each step. As noted in the paper LINK, this is a very stable and popular choice.
B. -space (Data Prediction)
Perhaps the most intuitive alternative is to have the model directly predict the clean image, , from the noisy input .
- Model:
- Weighted Loss:
- Intuition: At every step, the model tries to make its best guess of the final, clean image.
This is a very simple change from an implementation perspective. The blog post "Three Stable Diffusion Training Losses" provides a clear code-level view.
Three Stable Diffusion Training Losses: x0, epsilon, and v-prediction
This blog post shows how trivial it is to switch between prediction targets in a typical implementation.
Read the section 'x0 and eps'. Notice in the p_losses function how target is simply assigned to noise for epsilon-prediction or x_start for x0-prediction.
While simple, predicting has a practical challenge. As , becomes almost pure noise. The task of recovering becomes extremely difficult, which can lead to high variance in the loss for later timesteps.
C. -space (Score Prediction)
This brings us back full circle to the score-matching foundation we discussed two lessons ago. The score, , is the direction of steepest ascent in the log-probability of the noisy data distribution.
- Model:
- Key Relationship: For Gaussian noise, the score is directly proportional to the noise: . This means predicting the score is equivalent to predicting a scaled version of the noise.
- Weighted Loss:
- Intuition: The model learns the vector field that points from noisy data towards regions of higher data density.
To see how score-matching objectives are constructed and optimized, this video provides an excellent deep dive.
Diffusion and Score-Based Generative Models
The video 'Diffusion and Score-Based Generative Models' by Yang Song explains how score-based models are trained. This will connect the s-space loss to the broader field of score-based generative modeling.
Please watch the following segments: Score Matching Objective (18:57 - 21:49): Understand the basic 'Fisher Divergence' objective that compares the true data score to the model's score. Denoising Score Matching (27:37 - 31:33): This is the key. See how adding noise to the data (like in diffusion) makes the score matching objective tractable and leads to a loss that depends on predicting the score of the perturbed data distribution. Noise Conditional Models (40:37 - 44:08): See how this is extended to multiple noise levels by training a single model conditioned on the noise level \sigma (or timestep t). This directly corresponds to the DDPM training setup.
This establishes that the DDPM framework can be seen as a specific implementation of a more general noise-conditional score-matching model.
D. -space (Velocity Prediction)
A more recent and highly effective formulation is -prediction, introduced in the paper "Progressive Distillation for Fast Sampling of Diffusion Models".
- Target:
- Model:
- Weighted Loss:
- Intuition: The target is a combination of the noise and the data. The name comes from an interpretation of the diffusion process as a particle moving along a path; represents its velocity. A key benefit is that it has a unit-norm variance, making it well-behaved across all timesteps. It avoids the issues of -prediction at high noise and -prediction at low noise, proving especially useful for model distillation and few-step sampling.
Three Stable Diffusion Training Losses: x0, epsilon, and v-prediction
The blog post we looked at earlier also provides a good, practical summary of v-prediction.
Now read the section on 'v-prediction'. Note its formulation as a weighted sum of x0 and eps, and the author's empirical observation that it often performs better, especially for conditional generation.
3. Comparing the Formulations: Theory vs. Practice
Now that we have these four different "spaces" (), how do they compare?
Loss Functions in Diffusion Models: A Comparative Study
The paper 'Loss Functions in Diffusion Models' systematically analyzes the relationships and empirical differences between these formulations. This is the main takeaway of our lesson.
Please study this paper from Section 3.1 through to the Conclusion (Section 5). Focus on these key points: Sections 3.1 - 3.4: Skim the loss equations for each space. You don't need to re-derive them, but recognize their structure. Section 3.5 (Equivalence): This is crucial. Understand why all NELBO formulations are theoretically equivalent, but the simplified 'weighted losses' are not. Section 4.2 (Experiments): Pay close attention to the discussion and figures. Note the differences in loss convergence vs. sample quality, and how the loss behaves across timesteps for different targets (Fig. 8).
Let's distill the key findings from that paper:
- Theoretical Equivalence: When using the full, un-simplified NELBO loss, all four formulations are mathematically equivalent. A perfect model trained on any of these NELBO losses would converge to the same solution.
- Practical Non-Equivalence: The simplified, un-weighted (or differently weighted) losses that are commonly used in practice are not equivalent. They place different emphasis on different timesteps.
- Likelihood vs. Sample Quality: Better likelihood (a lower NELBO loss) does not always correlate with better perceptual quality (e.g., lower FID score). For instance, the paper finds that -space and -space achieve better likelihoods, but -space and -space can produce better samples.
- Behavior Across Timesteps:
- -space loss is highest for large (high noise), as predicting the clean image from pure noise is very hard.
- -space loss is highest for small (low noise). Predicting a small noise vector requires high precision relative to the signal.
- -space loss is more uniform across timesteps, which contributes to its training stability.
Test your understanding!
Consider a scenario where your generated images are consistently blurry and lack fine, high-frequency details (e.g., fabric textures, sharp edges). Based on how the different loss formulations behave across timesteps, which prediction space ( or ) might you hypothesize is better at learning these fine details, and why?
Show answer
The -space formulation is likely better for learning fine details. The loss for -prediction is highest at early timesteps ( is small), when the image is still mostly clean. At this stage, the model is penalized for failing to predict the small amount of noise that has been added. To do this accurately, it must have a very precise representation of the existing high-frequency details in the image.
Conversely, the -space loss is lowest at these early timesteps (predicting a clean image from a slightly noisy one is easy) and highest when the image is mostly noise. In the high-noise regime, the model is primarily focused on recovering the low-frequency global structure, not fine textures.
Conclusion
This lesson concludes our foundational module on diffusion theory. We've moved beyond the single DDPM objective to a more general understanding of the design choices available.
Key Takeaways:
- The standard DDPM training objective is a simplified, weighted loss where the model predicts the added noise ().
- This is just one of four common formulations. The model can also be trained to predict the clean data (), the score (), or a velocity term ().
- While the full NELBO-derived losses are theoretically equivalent, the simplified versions used in practice are not. They implicitly re-weight the objective, emphasizing different parts of the denoising process.
- The choice of prediction target is a practical one with significant trade-offs:
- -prediction is stable and works well.
- -prediction is intuitive but can be unstable at high noise levels.
- -prediction provides a direct link to score-based generative modeling.
- -prediction offers improved stability and is particularly effective for few-step sampling and model distillation.
You now have a robust theoretical toolkit to understand, debug, and make informed decisions about the core training dynamics of diffusion models.
Next Lesson Preview:
Now that we have a solid understanding of how diffusion models are trained, we'll shift our focus to the other side of the process: inference and sampling. In the first lesson of our next module, "Advanced Sampling and Inference," we will implement the basic DDPM ancestral sampling algorithm and begin to explore how different choices, such as the noise schedule, can impact the speed and quality of the images we generate.