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 5 · Coupling-based Gaussianization

The flows of Part 4 Gaussianize each coordinate with a map of its own, and only their rotations mix the coordinates. A coupling layer lets the map of one coordinate depend on the others: it copies half of the coordinates and transforms the other half with a one-dimensional map whose parameters a neural network, the conditioner, computes from the copied half. Its Jacobian is triangular, so the log-determinant is a sum, and its inverse runs the network forwards, so the network can be as large as we like. This part builds the pattern piece by piece with the couplings of gauss_flows, then compares coupling flows with the diagonal flows of Part 4.

#NotebookWhat you take away
00The coupling patternsplit, condition, transform (1); a fresh gauss_flows coupling is the identity on purpose (all but the deep sigmoid); the Jacobian is triangular (3), so the log-determinant is a sum over the active half (4); the inverse runs the conditioner forwards (5), exact for an affine transformer and to the bisection’s tolerance for a mixture CDF
01The transformer menuthe four transformers of gauss_flows (affine, mixture CDF, deep sigmoid (1), rational-quadratic spline); three start as the identity and the deep sigmoid does not; the affine map of one coordinate is a line and the others bend; with two coupling blocks on a spiral the spline fits best and the mixture CDF comes close behind, while the affine and deep-sigmoid flows end well behind; the mixture-CDF and deep-sigmoid layers get their weights perturbed before training to work around a bug (gauss_flows#265)
02Conditioner architecturesevery weight of a coupling is its conditioner’s; a wider conditioner fits better on the training rows and on the median held-out row, up to width 64, most between widths 8 and 16; log-scale bounds of 3 and 5 train alike, while a bound of 50 starts far higher and fits worst; the networks later parts put in the conditioner’s place
03Mask designa stack whose couplings all use one mask copies the passive half through every layer (1): trained on two moons, its first latent coordinate is the data’s, bit for bit; a flip between layers (2) costs no parameters, Gaussianizes that coordinate and lowers the held-out NLL from 1.84 to 1.64 nats; the mixture-CDF couplings get a 0.1 ε weight perturbation first, to work around gauss_flows#265; channel-wise masks for vectors, checkerboard masks for images
04Diagonal against couplinga diagonal layer’s marginal Jacobian is diagonal (1), a coupling layer’s is not; coupling_gaussianization_flow taken apart (spline coupling and a flip, over a hundred times the parameters of a diagonal layer); on a spiral at matched parameter counts the diagonal flow gets no better with depth (2.63 to 2.72 nats held out), while a coupling flow with a small conditioner is 0.83 nats better at a similar count and improves to 1.54 nats
05RBIG warm start for coupling flowsevery fresh coupling has a zero readout (1), so what fit_rbig_coupling adds is the EM mixtures in the readout’s bias; the warm start is a marginal map until training; a fresh mixture coupling needs its weights nudged before training (gauss_flows#265); at the same 3,000 steps the warm start leads early and on the training rows, but overfits and ends 0.24 to 0.50 nats worse held out at every learning rate
06Coupling and diagonal equivalencea coupling with a constant conditioner is a marginal map (1); with four layers fit_rbig_coupling matches fit_rbig layer by layer with about 220 times the parameters; with eight it parts at layer 5, where the coupling’s CDF clip (gauss_flows#260) caps at 4.75 a training point that the diagonal flow sends to 5.25
07Depth, gradients and residual mapson a spiral, held-out NLL is best at four spline layers and deeper flows overfit; at the identity start the gradient grows like K\sqrt{K}; a residual map (1) inverts by fixed-point iteration (2) only when its branch is a contraction

Three examples go further than these notebooks: the coupling-flow example trains a mixture-CDF coupling flow on two moons, the warm-start example shows a coupling flow’s warm start before training, and the coupling-equivalence example derives the equivalence of notebook 06 as three lemmas and a theorem.