UP.T1 — The Lemma of the Course

Flow-Based Generative Models · UFRJ · 2026.2

01Why this session exists

Where this course is going

  • Discrete flows. Build the map out of invertible layers. Exact likelihood, restricted map.
  • Continuous time. Let the map be the solution of a differential equation. The restriction goes; training now runs a solver inside every step.
  • Flow Matching. Stop asking for the likelihood. Regress against a target you can write down.

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

Three objects share one notation

Ask it of every conditional expectation you meet: which panel is this?

The three objects, separated in time

03The projection Lemma

The statement

Write \(f^{*}(y) = \mathbb{E}[X \mid Y = y]\).

Then for every square-integrable function \(f\) of \(Y\): \[ \mathbb{E}\big\Vert f(Y) - X \big\Vert^{2} = \mathbb{E}\big\Vert f^{*}(Y) - X \big\Vert^{2} + \mathbb{E}\big\Vert f(Y) - f^{*}(Y) \big\Vert^{2} . \] So \(f^{*}\) minimizes the left side, and it is the only minimizer.

Square-integrable, throughout: \(\mathbb{E}\Vert X\Vert^{2} < \infty\) and \(\mathbb{E}\Vert f(Y)\Vert^{2} < \infty\).

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

What the picture says

The vertical edge is a floor. The horizontal edge is the only part training can move.

The angle that never opens

04The announcement

This Lemma will be used exactly three times

  1. U3.T1 — to define the marginal velocity field: it is a conditional expectation of conditional velocities.
  2. U3.T2 — to prove the CFM theorem: swapping the unknown marginal target for a conditional surrogate leaves \(\theta\)-gradients unchanged (corollary (b)).
  3. U3.T2, detour D2 — to derive denoising score matching: same three lines, different random variables.

Tattoo it somewhere.

05Pushforwards, and what a model is

Pushforward

\(\psi_{\#}\, p\) is the distribution 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 } g . \]

Read it as an instruction: to sample from \(\psi_{\#}\, p\), sample from \(p\) and apply \(\psi\).

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.

A 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

\[ \operatorname*{arg\,max}_{\theta}\; \mathbb{E}_{x_1 \sim q}\big[ \log p_\theta(x_1) \big] \;=\; \operatorname*{arg\,min}_{\theta}\; \mathrm{KL}\big(q \,\Vert\, p_\theta\big) . \]

Two lines: expand the divergence, drop the term with no \(\theta\) in it.

The data sits in the first argument — the mass-covering direction of the primer’s §3.3.

But maximum likelihood needs \(\log p_\theta(x_1)\), and the definition above only gives you samples.

06What comes next

Why likelihoods will be hard

Unit Strategy What it costs
U1 invertible by construction what the map is allowed to be
U2 volume change by calculus a solver inside every training step
U3 refuse to play nothing yet — this is where the Lemma returns

And one thing that cannot even be written down yet: comparing two whole paths of distributions, rather than two distributions.

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]\) in closed form, from the toolkit sheet.

(b) In \(d = 1\): train a small network on samples \((y, x)\) with the square loss. Plot it against your closed form.

(c) Replace the target \(X\) by \(Z = X + \eta\) with \(\mathbb{E}[\eta \mid Y] = 0\). Retrain. The losses differ; the learned function does not.

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.