UP.T1 — The Lemma of the Course

Flow-Based Generative Models · UFRJ · 2026.2

01Why this session exists

Where this course is going

  • Normalizing Flows (U1). Build the transport out of invertible layers with a tractable inverse and Jacobian. Exact likelihood; the price is architectural restriction.
  • Continuous Normalizing Flows (U2). Let the transport be the flow map of a Neural ODE. Invertibility from well-posedness, volume change tracked continuously; the price is numerical integration.
  • Flow Matching (U3). Learn the velocity field by regression against targets you can sample. Likelihood is not required for training.

Today is none of those. Today is the foundation all three stand on.

The promise made today

We prove one result. Then we announce, on one slide, the three later sessions that use it.

When each of those three moments arrives, I will point back at this board.

Everything else in this session exists so that the promise can be stated precisely.

02Conditional expectation, done properly

The value, the function, and the random variable

\(m(y)\) is a value · \(m\) is a function · \(m(Y) = \mathbb{E}[X \mid Y]\) is a random variable. Ask it of every conditional expectation you meet: which panel is this?

The three objects, separated in time

03The projection Lemma

The statement

Let \(m(y) = \mathbb{E}[X \mid Y = y]\), and write \(f^{*} := m\). For every square-integrable \(f(Y)\): \[ \begin{aligned} &\mathbb{E}_{(x, y) \sim p_{XY}}\big[\, \Vert f(y) - x \Vert^{2} \,\big] \\[2pt] &\qquad\;=\; \mathbb{E}_{(x, y) \sim p_{XY}}\big[\, \Vert m(y) - x \Vert^{2} \,\big] \;+\; \mathbb{E}_{y \sim p_Y}\big[\, \Vert f(y) - m(y) \Vert^{2} \,\big] . \end{aligned} \] So \(m\) minimizes the population risk: \(m(Y)\) is the unique minimizer, \(\mathbb{P}\)-a.s.; \(m(y)\) is unique \(p_Y\)-a.e.

Square-integrable, throughout: \(\mathbb{E}_{x \sim p_X}[\Vert x\Vert^{2}] < \infty\) and \(\mathbb{E}\Vert f(Y)\Vert^{2} < \infty\).

The proof is on the board: one expansion, and one cross term that dies.

What the picture says

The vertical edge is the irreducible \(L^{2}\) error among predictors that use only \(Y\). The horizontal edge measures how far the chosen predictor is from the optimal one.

The angle that never opens

04The announcement

This Lemma will be used exactly three times

  1. U3.T1 — after the continuity-equation argument identifies the marginal velocity field as a conditional expectation of conditional velocities, to recognize that field as the \(L^{2}\)-optimal regression target given the current state.
  2. U3.T2 — to prove the CFM theorem: swapping the unknown marginal target for a conditional surrogate changes the population objective only by a \(\theta\)-independent constant and therefore leaves the \(\theta\)-gradients unchanged wherever those gradients exist (corollary (b)).
  3. U3.T2, detour D2 — to derive denoising score matching: same projection argument, different random variables.

05Pushforwards, and what a model is

Pushforward

\(\psi_{\#}\, p\) is the law of \(\psi(x)\) when \(x \sim p\): \[ \mathbb{E}_{y \sim \psi_{\#} p}\big[ g(y) \big] = \mathbb{E}_{x \sim p}\big[ g(\psi(x)) \big] \quad \text{for every bounded measurable } g . \]

It also gives the sampling rule: draw \(x \sim p\) and return \(\psi(x)\); the result has law \(\psi_{\#}\, p\). As a set formula, \((\psi_{\#} p)(A) = p(\psi^{-1}(A))\) — a probability law always, a density not necessarily.

You built one in the primer: \(x = \mu + \sigma\varepsilon\) is \(\mathcal{N}(\mu, \sigma^2) = \psi_{\#}\,\mathcal{N}(0,1)\).

The symbol \(\psi_{\#}\) is the course standard, after (Lipman et al. 2024) §3.3 — which states it for diffeomorphisms; any measurable \(\psi\) will do here.

A transport-based generative model is a pushforward of noise

\[ p_\theta = \big(\psi^{\theta}\big)_{\#}\, p_0 , \qquad p_0 = \mathcal{N}(0, I_d) \]

Maximum likelihood is a KL

With \(\mathcal{J}(\theta) = \mathbb{E}_{x_1 \sim q}[\log p_\theta(x_1)]\) and \(C_q = \mathbb{E}_{x_1 \sim q}[\log q(x_1)]\), \[ \begin{gathered} \mathrm{KL}\big(q \,\Vert\, p_\theta\big) \;=\; C_q - \mathcal{J}(\theta) , \\[2pt] \text{so}\quad \operatorname*{arg\,max}_{\theta}\; \mathcal{J}(\theta) \;=\; \operatorname*{arg\,min}_{\theta}\; \mathrm{KL}\big(q \,\Vert\, p_\theta\big) . \end{gathered} \]

Under: \(q\) and \(p_\theta\) with densities; \(q \ll p_\theta\) (necessary for a finite KL, not sufficient); \(C_q\) and \(\mathcal{J}(\theta)\) finite. Two lines: expand the divergence; the term with no \(\theta\) is \(C_q\). The empirical MLE objective is the sample average of \(\mathcal{J}\).

The problem this creates

The data sits in the first argument — mass-covering pressure, in the primer’s restricted-family heuristic.

But maximum likelihood needs \(\log p_\theta(x_1)\), and the pushforward definition alone gives no tractable way to evaluate it.

Three distinct things: the density exists (assumed above) · it has an expression · it can be evaluated tractably. The objective needs the third.

06What comes next

Why likelihoods will be hard

Unit Strategy The price
U1 Normalizing Flows invertible by construction: inverse and Jacobian tractable architectural restriction
U2 Continuous NFs flow map of a Neural ODE; invertibility from well-posedness; volume change tracked continuously numerical integration, everywhere
U3 Flow Matching change the objective: regress a velocity field on targets you can sample no likelihood needed for training — the Lemma returns, three times

Sampling: draw from the source and transport the sample. Density evaluation: track how probability density changes under that transport.

PS1.2 — the Lemma, in closed form and on a machine

\(X \sim \mathcal{N}(\mu_0, \sigma_0^{2} I_d)\), and \(Y = X + \sigma\varepsilon\).

(a) Compute \(\mathbb{E}[X \mid Y = y]\) and \(\operatorname{Cov}(X \mid Y = y)\) in closed form, from the toolkit sheet.

(b) In \(d = 1\): train a small network on samples \((y_i, x_i)\) with the empirical square loss. Plot it against \(m(y) = 0.8\, y\) on the evaluation grid.

(c) Replace the target \(X\) by \(Z = X + \eta\), \(\eta \sim \mathcal{N}(0, \tau^{2})\), \(\eta \perp (X, Y)\). On paper: \(\mathcal{L}_Z = \mathcal{L}_X + \tau^{2}\), and the finite-sample difference is not a constant. Then several seeds, two sample sizes: same population target; summarize the finite-sample behaviour across seeds.

This exercise has a secret identity, to be revealed in U3.

References

Lipman, Yaron, Marton Havasi, Peter Holderrieth, Neta Shaul, Matt Le, Brian Karrer, Ricky T. Q. Chen, David Lopez-Paz, Heli Ben-Hamu, and Itai Gat. 2024. “Flow Matching Guide and Code.” https://arxiv.org/abs/2412.06264.