The preceding chapters have described what to learn — a velocity field, a score function, a drift, a generator — and where to learn it — Euclidean space, manifolds, discrete spaces, product spaces. This chapter addresses how to learn it: what loss function to minimize, what the neural network should output, how to weight the loss across noise levels and time steps, and what to do when you have an energy function instead of data. These are not minor implementation details. The choice of training objective, parameterization, and noise schedule can change FID by a factor of two without changing any other component of the system. Understanding the full design space — and why the choices interact the way they do — is essential for practice.
The chapter also resolves a puzzle that has been implicit since Chapter 3: the denoising objective of DDPM, the score matching objective of NCSN, the velocity regression of flow matching, and the conditional flow matching loss are all different-looking objectives that produce the same (or equivalent) models. Why? The answer is that they are all instances of a single principle — regression against conditional targets — applied with different parameterizations and different weighting functions. The framework that unifies them is the subject of this chapter.
12.1 Maximum Likelihood and Change of Variables
The oldest training objective for generative models is maximum likelihood: choose parameters to maximize , where is the model density. For normalizing flows (Chapter 1), the model density is computed via the change-of-variables formula:
where is the flow map and is the base distribution. For continuous normalizing flows (Chapter 2), the log-determinant is replaced by a trace integral:
where is the ODE trajectory starting from and running backward to .
Maximum likelihood has a compelling theoretical property: minimizing is equivalent to minimizing , the forward KL divergence. The forward KL is mode-covering — it penalizes the model for assigning low density to any region where the data has support, encouraging the model to spread its mass across all data modes.
[!remark] 12.1 The fundamental problem with maximum likelihood for flow models is computational cost. Evaluating requires either computing the Jacobian determinant (which costs for a general -dimensional map, reduced to for coupling layers with triangular Jacobians) or integrating the trace along an ODE trajectory (which requires neural network evaluations per training step for CNFs). The entire trajectory from flow matching (Chapter 4) to the present was driven by the desire to avoid this cost.
12.2 Regression Losses: The Simulation-Free Revolution
The central insight of flow matching is that the intractable maximum-likelihood objective can be replaced by a regression loss — a simple squared-error between the network output and a known target — without changing the optimal model. This is the simulation-free revolution, and it applies far beyond flow matching.
[!definition] 12.1 — Conditional Regression Loss Given a probability path and a target function that depends on the current state and the conditioning data point , the conditional regression loss is:
where is the neural network output.
The regression loss has three decisive advantages over maximum likelihood: (1) no Jacobian determinant or trace integral is needed; (2) no ODE simulation is needed — is sampled directly from the known conditional distribution ; (3) the target is known in closed form for standard interpolants. The cost per training step is a single forward-backward pass through the network — the same as for any supervised learning problem.
Different choices of target and interpolant produce all the standard training objectives:
| Method | Target | Interpolant | Network predicts |
|---|---|---|---|
| Flow matching | Linear: | Velocity field | |
| DDPM (-prediction) | VP: | Noise | |
| DDPM (-prediction) | VP: | Clean data | |
| Score matching | VP: same | Score |
[!proposition] 12.1 — Equivalence of Parameterizations For a fixed interpolant (e.g., the VP-SDE schedule), the -prediction, -prediction, velocity-prediction, and score-prediction parameterizations are related by invertible affine transformations. At convergence, they produce the same model — the same probability flow ODE, the same generated distribution. They differ only in the weighting of the loss across noise levels and in the variance of the training gradient.
The proof is direct: for the VP-SDE interpolant , the relationships are:
Given any one of and the current state , the other three can be computed. The choice of parameterization does not change what is learned — only how the loss weights different noise levels.
12.3 Score Matching and Its Variants
Score matching trains a model to approximate the score function of the data distribution. The original objective (Hyvärinen, 2005) is the Fisher divergence:
This is intractable as written — is unknown. Three techniques make it tractable:
Implicit score matching (Hyvärinen, 2005): expand the squared norm and integrate by parts to eliminate the unknown score:
The trace term involves the diagonal of the Jacobian of — computable but expensive ( backward passes or Hutchinson trace estimation).
Denoising score matching (Vincent, 2011): instead of matching the score of , match the score of the noised distribution , whose score at a noisy sample is simply:
This is the Tweedie formula: the score of the noised distribution points from the noisy observation toward the clean data point. Training reduces to regression against — no Jacobian, no integration by parts.
Sliced score matching (Song, Garg, Shi, and Ermon, 2020): project the score onto random directions , reducing the -dimensional matching problem to a one-dimensional one:
Each term requires only one directional derivative — a single backward pass regardless of .
12.4 Energy-Based Training: When You Have the Density
All the objectives above assume access to samples . In some applications — notably molecular simulation and statistical physics — the target distribution is known up to a normalizing constant: , where is the energy function and is the (intractable) partition function. Samples are not available, but the energy can be evaluated at any point.
[!definition] 12.2 — Energy-Based Training (Reverse KL) Given a target density and a generative model (defined by a flow map ), the reverse KL training objective is:
The reverse KL is mode-seeking: it penalizes the model for placing mass where the target has low density, producing sharp but potentially incomplete approximations. This contrasts with the forward KL used in maximum likelihood, which is mode-covering.
The gradient of the reverse KL is:
which requires: (1) sampling from the model (by running the flow forward on noise ), (2) evaluating (by computing the log-determinant or trace integral), and (3) evaluating and its gradient at the generated sample. The partition function drops out of the gradient — it is a constant with respect to .
[!remark] 12.2 Energy-based training inverts the usual data pipeline: instead of learning from examples, the model learns from the energy function directly. This is natural for physics — the Boltzmann distribution is defined by , not by samples — and it avoids the sampling bottleneck that makes molecular simulation expensive in the first place. The model is both the approximation to the distribution and the sampler: generate from , then reweight by importance sampling if needed. The effective sample size , where , measures how close is to .
12.5 The Equivalence of Objectives
A unifying perspective emerges: all the training objectives in this chapter are instances of regression against conditional targets, weighted by a time- and noise-dependent function. The general form is:
where is the weighting function, is the target, and is sampled from the conditional path. Different choices of recover:
- Unweighted flow matching: ,
- DDPM simple loss: , (noise prediction)
- DDPM variational loss: , (derived from the ELBO)
- Score matching at noise level : , (the SNR-weighted Fisher divergence)
The weighting function determines how much the loss emphasizes different noise levels. This has a dramatic effect on sample quality:
- Uniform weighting (): treats all noise levels equally. The loss is dominated by high-noise regions where the target is large (the velocity or score is large when the signal-to-noise ratio is low), which biases the model toward coarse structure at the expense of fine details.
- SNR weighting (): upweights low-noise regions where fine details are resolved. Produces sharper samples but can underfit the coarse structure.
- Min-SNR weighting (Hang et al., 2024): for a clipping threshold . Balances coarse and fine structure by capping the weight at high SNR. This is the current best practice for diffusion training.
12.6 Noise Schedules and Their Geometry
The noise schedule determines how the signal-to-noise ratio evolves over time. For the general Gaussian interpolant , the SNR at time is:
Common choices:
- Linear (flow matching): , . SNR , monotonically increasing from 0 to . The schedule spends equal time at all SNR levels — a uniform distribution on the “information content” of the noisy sample.
- VP (variance-preserving): where . SNR . The schedule is determined by , typically linear or cosine.
- Cosine (Nichol and Dhariwal, 2021): for a small offset . Produces a nearly uniform distribution of over time, which empirically gives the best image quality.
- Trigonometric (Stable Diffusion 3): , . SNR . The schedule traverses the full SNR range smoothly, with distributed as a shifted logistic.
[!proposition] 12.2 — Noise Schedule Equivalence For a fixed model architecture and fixed training budget, the optimal noise schedule is the one that distributes uniformly over the time interval . Schedules that spend too much time at extreme SNR values (very high or very low) waste training capacity on noise levels that are either trivial (pure signal) or uninformative (pure noise).
The geometric interpretation: in the space of , the optimal schedule moves at constant speed. This is the “geodesic” in the space of noise levels — the schedule that extracts maximum information per training step.
12.7 Parameterizations: What Should the Network Predict?
Given the same interpolant and noise schedule, the network can predict different quantities. The three standard parameterizations are:
-prediction. The network outputs , the noise that was added to the data. Given , the predicted data is .
-prediction. The network outputs , the clean data directly. The predicted noise is .
-prediction (Salimans and Ho, 2022). The network outputs , a linear combination of noise and data that is numerically well-conditioned across all noise levels:
where the second equality holds for the trigonometric schedule , .
[!remark] 12.3 The practical differences between parameterizations are entirely about numerical conditioning. At high noise (), the -prediction target is while the -prediction target is — huge and poorly conditioned. At low noise (), the situation reverses: -prediction is while -prediction is . The -prediction is at both extremes — it is the “natural” parameterization for schedules where and have comparable magnitude throughout.
This is why -prediction has become the default for flow matching and modern diffusion models: the linear interpolant gives , which is everywhere. The DDPM -prediction works well for the VP-SDE schedule (where high-noise regions dominate training) but is poorly conditioned for the linear schedule. Matching the parameterization to the noise schedule is essential for stable training.
12.8 Practical Recipes
Combining the design choices of this chapter, the current best practices for training transport-based generative models are:
For image generation with flow matching:
- Interpolant: linear or trigonometric
- Parameterization: velocity (-prediction)
- Weighting: uniform or lognormal time sampling (sample from a lognormal centered at the midpoint of the SNR range)
- Architecture: Diffusion Transformer (DiT) with adaptive layer norm
- OT conditioning: mini-batch OT with batch size
For molecular generation with equivariant flows:
- Interpolant: linear on coordinates, often with center-of-mass removal
- Parameterization: velocity (-prediction) with -equivariant architecture
- Weighting: uniform time sampling
- Conservation: projected zero-COM velocity (Equation 11.2)
- Architecture: EGNN, PaiNN, or MACE backbone
For energy-based training (Boltzmann generators):
- Objective: reverse KL (Equation 12.3) or flow matching with energy-based reweighting
- Architecture: equivariant flow with exact log-likelihood (for importance sampling)
- Evaluation: effective sample size (ESS) as primary metric
- Refinement: sequential Monte Carlo or annealed importance sampling post-training
12.9 Historical Notes
Maximum likelihood training for normalizing flows was introduced by Rezende and Mohamed (2015) and developed through the coupling-flow era (NICE, RealNVP, Glow). The simulation-free insight arose simultaneously in Lipman et al. (2022), Albergo and Vanden-Eijnden (2022), and Liu et al. (2022), as described in Chapter 4.
Score matching was introduced by Hyvärinen (2005) (“Estimation of Non-Normalized Statistical Models by Score Matching”). Denoising score matching was established by Vincent (2011) (“A Connection Between Score Matching and Denoising Autoencoders”), who proved the equivalence with Tweedie’s formula. Sliced score matching was introduced by Song, Garg, Shi, and Ermon (2020). The multi-scale score matching approach (training at multiple noise levels simultaneously) was developed by Song and Ermon (2019, 2020) (NCSN, NCSNv2).
The DDPM training objective and the equivalence between noise prediction and score matching was established by Ho, Jain, and Abbeel (2020) and analyzed systematically by Kingma, Salimans, Poole, and Ho (2021) (“Variational Diffusion Models”), who derived the optimal time-weighting from the variational bound. The -prediction parameterization was introduced by Salimans and Ho (2022) (“Progressive Distillation for Fast Sampling of Diffusion Models”). The min-SNR weighting strategy was proposed by Hang, Gu, Li, Bao, Li, Zhang, and Guo (2024) (“Efficient Diffusion Training via Min-SNR Weighting Strategy”).
The cosine noise schedule was introduced by Nichol and Dhariwal (2021) (“Improved Denoising Diffusion Probabilistic Models”). The systematic exploration of the design space — noise schedule, parameterization, weighting, sampler — was carried out by Karras, Aittala, Aila, and Laine (2022) (“Elucidating the Design Space of Diffusion-Based Generative Models”), which remains the most comprehensive analysis of these choices and their interactions.
Energy-based training for generative flows was pioneered by Noé, Olsson, Köhler, and Wu (2019) (“Boltzmann Generators: Sampling Equilibrium States of Many-Body Systems with Deep Learning”), who demonstrated reverse KL training for molecular systems. The importance sampling framework and the ESS diagnostic were developed in this paper and extended by Midgley, Stimper, Simm, Schölkopf, and Hernández-Lobato (2023) (“Flow Annealed Importance Sampling Bootstrap”) and Klein, Krämer, and Noé (2024) (“Transferable Boltzmann Generators”).