Reverse SDE

Chapter 19 Dynamics & diffusion

Chapter 19: Stochastic Differential Equations — Reverse-Time SDE & Doob's $h$-Transform

From the book

Chapter 19: Stochastic Differential Equations. In the chapter mind map this icon labels Reverse-Time SDE & Doob's $h$-Transform. The discussion below is excerpted and lightly edited from § Reverse-Time SDE in Mathematics for AI and Machine Learning.

Under mild conditions (smooth drift and diffusion, non-degenerate diffusion) and for state-independent diffusion $\mathbf{G}(t)$, the time-reversed process satisfies

where time runs backward from $T$ to $0$ and $\bar{\mathbf{W}}_t$ is a Brownian motion in reversed time. When the diffusion depends on the state, with $\mathbf a = \mathbf G\mathbf G^\top$, the reverse drift gains a divergence term and becomes $\mathbf f - \nabla\cdot\mathbf a - \mathbf a\nabla_{\mathbf x}\log p_t$, where $(\nabla\cdot\mathbf a)_i = \sum_j \partial_j a_{ij}$. Diffusion models use state-independent noise, for which this term vanishes. The extra drift $-\mathbf{G}(t)\mathbf{G}(t)^\top \nabla_{\mathbf{x}}\log p_t(\mathbf{X}_t)$ undoes the spreading of the forward diffusion: the forward noise moves mass away from high-density regions, and the reverse drift moves it back, which requires knowing where those regions are. That information is exactly the score. At the level of densities the reverse drift follows from @eq:fokker-planck-sde in one line: with the reversed time $s = T - t$ and $q_s = p_{T-s}$, the forward equation gives $\partial_s q_s = \nabla\cdot(\mathbf f q_s) - \frac{1}{2}\nabla\cdot(\mathbf a\nabla q_s)$, and writing $-\frac{1}{2}\nabla\cdot(\mathbf a\nabla q) = -\nabla\cdot(q\,\mathbf a\nabla\log q) + \frac{1}{2}\nabla\cdot(\mathbf a\nabla q)$ turns it into $\partial_s q_s = -\nabla\cdot\big((-\mathbf f + \mathbf a\nabla\log q_s)q_s\big) + \frac{1}{2}\nabla\cdot(\mathbf a\nabla q_s)$, the Fokker–Planck equation of the drift $-\mathbf f + \mathbf a\nabla\log q_s$ with the same diffusion. That is @eq:reverse-time-sde read in the time $s$; Anderson's theorem adds that not only the marginals but the whole law of the paths is reversed.

This reverse-time SDE is the basis of reverse diffusion and score-based generative models: a forward process turns data $\mathbf{x}_0 \sim p_{\text{data}}$ into noise $\mathbf{x}_T \approx \mathcal{N}(\mathbf{0}, I)$, a neural network $\mathbf{s}_\theta(\mathbf{x}, t)$ is trained to approximate $\nabla_{\mathbf{x}} \log p_t(\mathbf{x})$, and the reverse process generates samples by solving the reverse SDE backward in time from noise to data.

For a one-dimensional check, let $dX_t = dW_t$ with $X_0 \sim \mathcal N(0, s^2)$. Then $p_t = \mathcal N(0, s^2 + t)$ and $\nabla\log p_t(x) = -x/(s^2 + t)$. In the reversed time $u = T - t$, with $c = s^2 + T$, the reverse SDE @eq:reverse-time-sde reads $dY_u = -\frac{Y_u}{c - u}\,du + dB_u$ with $Y_0 \sim \mathcal N(0, c)$. By Itô's lemma the variance $v(u) = \mathbb{E}[Y_u^2]$ obeys $v' = -\frac{2v}{c - u} + 1$, solved by $v(u) = c - u = s^2 + (T - u)$: at every reversed time the law is the forward marginal $p_{T-u}$, and at $u = T$ it is the data distribution $\mathcal N(0, s^2)$. The score term pulls the samples inward at exactly the rate the forward noise spread them; reversing the forward drift alone, here $-\mathbf f = 0$, would leave only noise and keep spreading them.

the book figure shows $50$ particle trajectories of an Ornstein-Uhlenbeck process. At $t = 0$ (left) the particles form two clusters (blue points). Going forward in time (black arrow), the forward SDE spreads and mixes them, and at $t = T$ (right) they form a Gaussian (gray points). The reverse SDE (red arrow) would carry the noise back to the clusters, but only with the score $\nabla_{\mathbf{x}} \log p_t(\mathbf{x})$ in its drift; this is why generation by time reversal needs score matching (the matrix chapter).

What this drawing shows

What you see. Time-reversed SDE denoises a sample from noise (gray, right) back to data (blue, left); animation traces the state along the red reverse arrow opposite the black forward corruption path.

In the mind map. Chapter 19 — Reverse-Time SDE & Doob's -Transform. See From the book above for definitions, figures, and worked examples.

Where to read next

Open Chapter 19 companion →

Read the full definitions, figures, and worked examples in Chapter 19: Stochastic Differential Equations — see the mind-map node Reverse-Time SDE & Doob's -Transform.

PNG Icons

Textless (256×256 px)
PNG 256×256 px Copy PNG URL
Textless (64×64 px)
PNG 64×64 px Copy PNG URL
Textless (32×32 px)
PNG 32×32 px Copy PNG URL

Animated GIFs

Animated GIF (256×256 px)
GIF 256×256 px Copy GIF URL
Animated GIF (128×128 px)
GIF 128×128 px Copy GIF URL
Animated GIF (64×64 px)
GIF 64×64 px Copy GIF URL