Antonio Franca
The Modern Framework · 12

Training Objectives, Losses, and Parameterizations

MLE, regression losses, score matching, energy-based training, and practical recipes

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 θ\theta to maximize Expdata[logpθ(x)]\mathbb{E}_{x \sim p_{\text{data}}}[\log p_\theta(x)], where pθp_\theta is the model density. For normalizing flows (Chapter 1), the model density is computed via the change-of-variables formula:

where TθT_\theta is the flow map and p0p_0 is the base distribution. For continuous normalizing flows (Chapter 2), the log-determinant is replaced by a trace integral:

logpθ(x)=logp0(x0)01vθ(xt,t)dt,\log p_\theta(x) = \log p_0(x_0) - \int_0^1 \nabla \cdot v_\theta(x_t, t)\, dt,

where xtx_t is the ODE trajectory starting from xx and running backward to x0x_0.

Maximum likelihood has a compelling theoretical property: minimizing E[logpθ(x)]-\mathbb{E}[\log p_\theta(x)] is equivalent to minimizing KL(pdatapθ)\mathrm{KL}(p_{\text{data}} \| p_\theta), 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 logpθ(x)\log p_\theta(x) requires either computing the Jacobian determinant (which costs O(d3)O(d^3) for a general dd-dimensional map, reduced to O(d)O(d) for coupling layers with triangular Jacobians) or integrating the trace vθ\nabla \cdot v_\theta along an ODE trajectory (which requires O(100)O(100) 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 {pt}\{p_t\} and a target function τt(x,x1)\tau_t(x, x_1) that depends on the current state xx and the conditioning data point x1x_1, the conditional regression loss is:

L(θ)=EtU[0,1],  x1pdata,  xpt(x1) ⁣[fθ(x,t)τt(x,x1)2],\mathcal{L}(\theta) = \mathbb{E}_{t \sim \mathcal{U}[0,1],\; x_1 \sim p_{\text{data}},\; x \sim p_t(\cdot|x_1)}\!\left[\|f_\theta(x, t) - \tau_t(x, x_1)\|^2\right],

where fθf_\theta 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 — xx is sampled directly from the known conditional distribution pt(x1)p_t(\cdot|x_1); (3) the target τt\tau_t 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 τt\tau_t and interpolant produce all the standard training objectives:

MethodTarget τt\tau_tInterpolantNetwork predicts
Flow matchingut(xx1)=x1ϵu_t(x \mid x_1) = x_1 - \epsilonLinear: xt=tx1+(1t)ϵx_t = tx_1 + (1-t)\epsilonVelocity field vθv_\theta
DDPM (ϵ\epsilon-prediction)ϵ\epsilonVP: xt=αˉtx1+1αˉtϵx_t = \sqrt{\bar\alpha_t}x_1 + \sqrt{1-\bar\alpha_t}\epsilonNoise ϵθ\epsilon_\theta
DDPM (xx-prediction)x1x_1VP: xt=αˉtx1+1αˉtϵx_t = \sqrt{\bar\alpha_t}x_1 + \sqrt{1-\bar\alpha_t}\epsilonClean data x^θ\hat{x}_\theta
Score matchingϵ/1αˉt-\epsilon / \sqrt{1-\bar\alpha_t}VP: sameScore sθlogpts_\theta \approx \nabla\log p_t

[!proposition] 12.1 — Equivalence of Parameterizations For a fixed interpolant (e.g., the VP-SDE schedule), the ϵ\epsilon-prediction, xx-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 xt=αˉtx1+1αˉtϵx_t = \sqrt{\bar\alpha_t}x_1 + \sqrt{1-\bar\alpha_t}\epsilon, the relationships are:

v=αˉ˙t2αˉtx1αˉ˙t21αˉtϵ,s=ϵ1αˉt,x1=xt1αˉtϵαˉt.v = \frac{\dot{\bar\alpha}_t}{2\sqrt{\bar\alpha_t}}x_1 - \frac{\dot{\bar\alpha}_t}{2\sqrt{1-\bar\alpha_t}}\epsilon, \qquad s = -\frac{\epsilon}{\sqrt{1-\bar\alpha_t}}, \qquad x_1 = \frac{x_t - \sqrt{1-\bar\alpha_t}\epsilon}{\sqrt{\bar\alpha_t}}.

Given any one of (v,s,ϵ,x1)(v, s, \epsilon, x_1) and the current state xtx_t, 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 sθ(x)xlogp(x)s_\theta(x) \approx \nabla_x \log p(x) to approximate the score function of the data distribution. The original objective (Hyvärinen, 2005) is the Fisher divergence:

This is intractable as written — xlogpdata\nabla_x \log p_{\text{data}} 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:

LISM=Epdata ⁣[tr(xsθ(x))+12sθ(x)2].\mathcal{L}_{\mathrm{ISM}} = \mathbb{E}_{p_{\text{data}}}\!\left[\mathrm{tr}(\nabla_x s_\theta(x)) + \tfrac{1}{2}\|s_\theta(x)\|^2\right].

The trace term tr(xsθ)\mathrm{tr}(\nabla_x s_\theta) involves the diagonal of the Jacobian of sθs_\theta — computable but expensive (O(d)O(d) backward passes or Hutchinson trace estimation).

Denoising score matching (Vincent, 2011): instead of matching the score of pdatap_{\text{data}}, match the score of the noised distribution pσ(x)=pdata(x1)N(x;x1,σ2I)dx1p_\sigma(x) = \int p_{\text{data}}(x_1)\mathcal{N}(x; x_1, \sigma^2 I)\, dx_1, whose score at a noisy sample x=x1+σϵx = x_1 + \sigma\epsilon is simply:

xlogpσ(x)x1xσ2=ϵσ.\nabla_x \log p_\sigma(x) \approx \frac{x_1 - x}{\sigma^2} = -\frac{\epsilon}{\sigma}.

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 (x1x)/σ2(x_1 - x)/\sigma^2 — no Jacobian, no integration by parts.

Sliced score matching (Song, Garg, Shi, and Ermon, 2020): project the score onto random directions vN(0,I)v \sim \mathcal{N}(0, I), reducing the dd-dimensional matching problem to a one-dimensional one:

LSSM=Ev,pdata ⁣[vxsθ(x)v+12(vsθ(x))2].\mathcal{L}_{\mathrm{SSM}} = \mathbb{E}_{v, p_{\text{data}}}\!\left[v^\top \nabla_x s_\theta(x)\, v + \tfrac{1}{2}(v^\top s_\theta(x))^2\right].

Each term requires only one directional derivative vxsθvv^\top \nabla_x s_\theta v — a single backward pass regardless of dd.

12.4 Energy-Based Training: When You Have the Density

All the objectives above assume access to samples xpdatax \sim p_{\text{data}}. In some applications — notably molecular simulation and statistical physics — the target distribution is known up to a normalizing constant: ptarget(x)=eβU(x)/Zp_{\text{target}}(x) = e^{-\beta U(x)} / Z, where U(x)U(x) is the energy function and Z=eβU(x)dxZ = \int e^{-\beta U(x)}\, dx 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 ptarget(x)eβU(x)p_{\text{target}}(x) \propto e^{-\beta U(x)} and a generative model qθq_\theta (defined by a flow map TθT_\theta), the reverse KL training objective is:

LRKL(θ)=KL(qθptarget)=Exqθ ⁣[logqθ(x)logptarget(x)]=Exqθ ⁣[logqθ(x)+βU(x)]+logZ.\mathcal{L}_{\mathrm{RKL}}(\theta) = \mathrm{KL}(q_\theta \| p_{\text{target}}) = \mathbb{E}_{x \sim q_\theta}\!\left[\log q_\theta(x) - \log p_{\text{target}}(x)\right] = \mathbb{E}_{x \sim q_\theta}\!\left[\log q_\theta(x) + \beta U(x)\right] + \log Z.

The reverse KL KL(qθptarget)\mathrm{KL}(q_\theta \| p_{\text{target}}) 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 KL(pdataqθ)\mathrm{KL}(p_{\text{data}} \| q_\theta) used in maximum likelihood, which is mode-covering.

The gradient of the reverse KL is:

which requires: (1) sampling from the model qθq_\theta (by running the flow forward on noise zz), (2) evaluating logqθ\log q_\theta (by computing the log-determinant or trace integral), and (3) evaluating UU and its gradient at the generated sample. The partition function ZZ drops out of the gradient — it is a constant with respect to θ\theta.

[!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 UU, 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 qθq_\theta, then reweight by importance sampling if needed. The effective sample size ESS=(iwi)2/iwi2\mathrm{ESS} = (\sum_i w_i)^2 / \sum_i w_i^2, where wi=ptarget(xi)/qθ(xi)w_i = p_{\text{target}}(x_i) / q_\theta(x_i), measures how close qθq_\theta is to ptargetp_{\text{target}}.

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 λ(t)0\lambda(t) \geq 0 is the weighting function, τ\tau is the target, and xtx_t is sampled from the conditional path. Different choices of (λ,τ)(\lambda, \tau) recover:

  • Unweighted flow matching: λ(t)=1\lambda(t) = 1, τ=x1ϵ\tau = x_1 - \epsilon
  • DDPM simple loss: λ(t)=1\lambda(t) = 1, τ=ϵ\tau = \epsilon (noise prediction)
  • DDPM variational loss: λ(t)=βt/(2σt2(1αˉt))\lambda(t) = \beta_t / (2\sigma_t^2(1-\bar\alpha_t)), τ=ϵ\tau = \epsilon (derived from the ELBO)
  • Score matching at noise level σ\sigma: λ(σ)=σ2\lambda(\sigma) = \sigma^2, τ=ϵ/σ\tau = -\epsilon/\sigma (the SNR-weighted Fisher divergence)

The weighting function λ(t)\lambda(t) determines how much the loss emphasizes different noise levels. This has a dramatic effect on sample quality:

  • Uniform weighting (λ=1\lambda = 1): 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 (λ(t)SNR(t)\lambda(t) \propto \text{SNR}(t)): 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): λ(t)=min(SNR(t),γ)\lambda(t) = \min(\text{SNR}(t), \gamma) for a clipping threshold γ\gamma. 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 xt=αtx1+σtϵx_t = \alpha_t x_1 + \sigma_t \epsilon, the SNR at time tt is:

Common choices:

  • Linear (flow matching): αt=t\alpha_t = t, σt=1t\sigma_t = 1-t. SNR =t2/(1t)2= t^2/(1-t)^2, monotonically increasing from 0 to \infty. The schedule spends equal time at all SNR levels — a uniform distribution on the “information content” of the noisy sample.
  • VP (variance-preserving): αt=αˉt\alpha_t = \sqrt{\bar\alpha_t} where αˉt=s=1t(1βs)\bar\alpha_t = \prod_{s=1}^t (1-\beta_s). SNR =αˉt/(1αˉt)= \bar\alpha_t/(1-\bar\alpha_t). The schedule is determined by βt\beta_t, typically linear or cosine.
  • Cosine (Nichol and Dhariwal, 2021): αˉt=cos2(πt/2(1+s)/(1+s))\bar\alpha_t = \cos^2(\pi t/2 \cdot (1+s)/(1+s)) for a small offset ss. Produces a nearly uniform distribution of logSNR(t)\log\text{SNR}(t) over time, which empirically gives the best image quality.
  • Trigonometric (Stable Diffusion 3): αt=cos(πt/2)\alpha_t = \cos(\pi t/2), σt=sin(πt/2)\sigma_t = \sin(\pi t/2). SNR =cot2(πt/2)= \cot^2(\pi t/2). The schedule traverses the full SNR range smoothly, with logSNR\log\text{SNR} 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 logSNR(t)\log\text{SNR}(t) uniformly over the time interval [0,1][0,1]. 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 logSNR\log\text{SNR}, 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:

ϵ\epsilon-prediction. The network outputs ϵθ(xt,t)ϵ\epsilon_\theta(x_t, t) \approx \epsilon, the noise that was added to the data. Given xt=αtx1+σtϵx_t = \alpha_t x_1 + \sigma_t \epsilon, the predicted data is x^1=(xtσtϵθ)/αt\hat{x}_1 = (x_t - \sigma_t \epsilon_\theta) / \alpha_t.

xx-prediction. The network outputs x^θ(xt,t)x1\hat{x}_\theta(x_t, t) \approx x_1, the clean data directly. The predicted noise is ϵ^=(xtαtx^θ)/σt\hat\epsilon = (x_t - \alpha_t \hat{x}_\theta) / \sigma_t.

vv-prediction (Salimans and Ho, 2022). The network outputs vθ(xt,t)αtϵσtx1v_\theta(x_t, t) \approx \alpha_t \epsilon - \sigma_t x_1, 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 αt=cos(πt/2)\alpha_t = \cos(\pi t/2), σt=sin(πt/2)\sigma_t = \sin(\pi t/2).

[!remark] 12.3 The practical differences between parameterizations are entirely about numerical conditioning. At high noise (σtαt\sigma_t \gg \alpha_t), the ϵ\epsilon-prediction target is O(1)O(1) while the xx-prediction target is O(σt/αt)O(\sigma_t/\alpha_t) — huge and poorly conditioned. At low noise (σtαt\sigma_t \ll \alpha_t), the situation reverses: xx-prediction is O(1)O(1) while ϵ\epsilon-prediction is O(αt/σt)O(\alpha_t/\sigma_t). The vv-prediction is O(1)O(1) at both extremes — it is the “natural” parameterization for schedules where αt\alpha_t and σt\sigma_t have comparable magnitude throughout.

This is why vv-prediction has become the default for flow matching and modern diffusion models: the linear interpolant xt=tx1+(1t)ϵx_t = tx_1 + (1-t)\epsilon gives v=x1ϵv = x_1 - \epsilon, which is O(1)O(1) everywhere. The DDPM ϵ\epsilon-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 xt=tx1+(1t)ϵx_t = tx_1 + (1-t)\epsilon or trigonometric xt=cos(πt/2)ϵ+sin(πt/2)x1x_t = \cos(\pi t/2)\epsilon + \sin(\pi t/2)x_1
  • Parameterization: velocity (vv-prediction)
  • Weighting: uniform or lognormal time sampling (sample tt 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 256\leq 256

For molecular generation with equivariant flows:

  • Interpolant: linear on coordinates, often with center-of-mass removal
  • Parameterization: velocity (vv-prediction) with SE(3)SE(3)-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 vv-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”).