Every flow so far learned one density . A conditional flow makes its map depend on a context , so that one set of weights learns a whole family : 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.
| # | Notebook | What you take away |
|---|---|---|
| 00 | Three ways to condition | the 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 ; on two moons labelled by crescent, reading the label is worth 0.715 nats per row (close to ), 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 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 (gauss_flows#272) |
| 01 | Conditional density estimation | the 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 (4) passes (Kolmogorov-Smirnov ), 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 , scores 0.43 nats worse and fails the test (), although its coverage at 80% is within a point |
| 02 | A conditional flow as an amortised posterior | the conditional NLL on simulated pairs trains the posterior, because its expectation is 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 ; 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.