Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Part 7 · Conditional Gaussianization

Every flow so far learned one density px(x)p_x(\vect{x}). A conditional flow makes its map depend on a context y\vect{y}, so that one set of weights learns a whole family px(x∣y)p_x(\vect{x} \mid \vect{y}): each slice of the data is sent to the same standard normal, the conditional log-likelihood stays exact, and a conditional sample is one pass of the flow. The training, the log-determinants and the samplers of Parts 4 to 6 carry over unchanged. This part shows where the context can enter (the base, the couplings, both, or a wrapper around the data) with the conditioning layers of gauss_flows, checks a conditional density against an exact one with a calibration test, and trains a conditional flow as an amortised posterior for an inverse problem.

#NotebookWhat you take away
00Three ways to conditionthe context can enter through the base (2), the couplings’ conditioner (3), both, or a FiLM wrapper around the data (4); every conditional flow starts as the identity in y\vect{y}; on two moons labelled by crescent, reading the label is worth 0.715 nats per row (close to log⁡2\log 2), and the base, the couplings and both tie within one standard error, unlike the conditional-flow example, whose ranking holds only in its own setup and changes between processes (gauss_flows#274); each slice of the conditional flows is within 0.008 nats of N(0,I)\mathcal{N}(\vect{0}, \mat{I}) after the standardisation (5); on a pair that differs by a pure shift of the data, the data-side wrapper beats the base by 0.040 ± 0.016 nats, so “condition the base for shifts” holds for shifts of the latent, not of the data; the zoo of conditioning layers (6) (concatenation, FiLM, a hypernetwork), zero_readout and pack_time_control; the conditional base’s float32 log⁡2π\log 2\pi (gauss_flows#272)
01Conditional density estimationthe conditional change of variables (3) on a two-dimensional family whose shape and dependence change with a continuous context (1), whose exact density (2) is the reference; a conditional RQSplineCoupling flow trained with pipekit-train reaches 2.299 nats on held-out rows against the exact 2.290; every slice maps to the same standard normal; a calibration test from ∥z∥2\lVert \vect{z} \rVert^2 (4) passes (Kolmogorov-Smirnov p=0.17p = 0.17), with coverage within 1.7 standard errors in every band of the context; an elementwise flow built from Conditioner-wrapped marginal splines (5) Gaussianizes each coordinate of every slice but keeps a correlation of ±0.80 at y=±1y = \pm 1, scores 0.43 nats worse and fails the test (p=1.5×10−10p = 1.5 \times 10^{-10}), although its coverage at 80% is within a point
02A conditional flow as an amortised posteriorthe conditional NLL on simulated pairs (x,Hx+ε)(\vect{x}, \mat{H} \vect{x} + \gvect{\varepsilon}) trains the posterior, because its expectation is H[x∣y]H[\vect{x} \mid \vect{y}] plus the expected KL from the exact posterior (3); on a linear-Gaussian problem with a closed-form posterior (4) the amortisation gap (5) is 0.026 ± 0.004 nats, against 2.3 nats of information per observation; per observation the KL is 0.01 to 0.03 nats in the bulk and rises to 0.56 and 2.6 nats at 3.6 standard deviations; on a two-moons prior the flow matches exact rejection draws (6) mode by mode (upper-moon share within one percentage point), with 2.2 per cent of its draws on trails between modes at y=0y = 0; 4,000 posterior draws take about 15 ms

The conditional-flow example trains the three placements of the context on two moons with its own settings.