Dynamics: Differential Equations and Generative Flows

Dive into Deep Learning · §38

Dynamics: Differential Equations, Stochastic Flows, and Transport
ODEs & solvers · Neural ODEs · Itô SDEs · Fokker–Planck PDE · score matching · flow matching

Why Deep Learning Needs Continuous-Time Dynamics

Motivation

  • Architectures & optimizers as Euler steps: A ResNet block \mathbf{x}_{l+1} = \mathbf{x}_l + \mathbf{f}(\mathbf{x}_l) (h=1) and gradient descent \mathbf{w}_{k+1} = \mathbf{w}_k - \eta\nabla\mathcal{L} (h=\eta) are forward-Euler steps of an ODE, capped at \eta < 2/\lambda_{\max}(\mathbf{H}).
  • Generative sampling by reversing noise: Adding Brownian kicks (\sim \sqrt{dt}) smooths p_t(\mathbf{x}) deterministically via the Fokker–Planck PDE, which can be reversed from \mathcal{N}(\mathbf{0}, \mathbf{I}) back to p_{\text{data}}.

The Three-Stage Mathematical Roadmap of Chapter 38

Architecture of the Chapter

  • Stage 1: Deterministic ODEs & Flows (§§38.1–38.3): Picard–Lindelöf uniqueness, matrix exponential e^{\mathbf{A}t}, Runge–Kutta stability R(h\lambda), continuous adjoint ODE, and Liouville’s trace rule \frac{d}{dt}\log p_t = -\operatorname{tr}\mathbf{J}.
  • Stage 2: Stochastic Calculus & Density Flow (§§38.4–38.5): Quadratic variation (dW)^2 = dt, Itô’s lemma, OU Gaussian kernels, Fokker–Planck PDE, Anderson’s reverse SDE, and the probability-flow ODE.
  • Stage 3: Learning Generative Fields (§§38.6–38.7): Vincent’s denoising score matching, Tweedie’s formula, DDPM/DDIM, Conditional Flow Matching, and Reflow.

Concrete Running Benchmarks Anchoring the Chapter

Pedagogical Thread

  • Linear & stiff ODEs: Planar spiral sink (\lambda = -0.5 \pm \mathrm{i}) and stiff two-mode decay (\mathrm{diag}(-50, -1)) test e^{\mathbf{A}t}, RK4 order, adjoints, and explicit step ceilings.
  • Stochastic & multimodal benchmarks: Ornstein–Uhlenbeck SDE (dX = -\theta X\,dt + g\,dW) and the bimodal Gaussian mixture test exact transition kernels, scores, reverse SDEs, and DDIM strides.
  • 2D transport benchmark: Two-moons paired with \mathcal{N}(\mathbf{0}, \mathbf{I}) tests crossing segments, the CFM floor C, and Reflow straightening.

Unifying Equations: Particles, Densities, Reversal

Core Dictionary

  • Forward & reverse SDEs: d\mathbf{X} = \mathbf{f}\,dt + g\,d\mathbf{W} reverses via d\mathbf{X} = [\mathbf{f} - g^2\nabla\log p_t]\,dt + g\,d\bar{\mathbf{W}}.
  • Deterministic probability-flow ODE: \dot{\mathbf{x}} = \mathbf{u}_t(\mathbf{x}) = \mathbf{f}(\mathbf{x}, t) - \tfrac12 g(t)^2\nabla\log p_t(\mathbf{x}) shares all marginals p_t(\mathbf{x}).
  • Key identity: Rewriting \tfrac12 g^2\Delta p_t = \nabla\cdot(p_t \cdot \tfrac12 g^2\nabla\log p_t) turns Laplacian diffusion into deterministic transport along the score field.

Prerequisites and Reading Paths Through Chapter 38

Study Guide

  • Mathematical Prerequisites: Eigendecompositions and spectral norms (§33), multivariable Jacobians, divergence, and integration by parts (§34), and Gaussian conditional expectations (§36). No measure theory is required.
  • Optimization & SSM Path (§38.1–38.2): Covers exact zero-order hold discretizations for State Space Models (Mamba/S4), non-normal transient growth in momentum, and numerical stiffness in gradient descent.
  • Fast-Track to Diffusion & Flow Models: Read §38.1–38.2 for flows and Runge–Kutta solvers, §38.4 for Itô’s lemma and the Ornstein–Uhlenbeck kernel, §38.5 for reverse-time SDEs and the probability-flow ODE, and §38.6–38.7 for score and flow matching.
  • Optional Deep Dives: You can skip the continuous adjoint method (§38.3) and Wasserstein optimal transport theory (§38.7) on a first pass toward image generation.