Coupling Flows: NICE, RealNVP & Glow
The coupling layer family: NICE's additive coupling, RealNVP's affine coupling, Glow's 1x1 convolutions, multi-scale architecture, and why these form the backbone of practical discrete normalizing flows.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- NICE: Additive Coupling
- RealNVP: Affine Coupling
- Glow: 1x1 Convolutions
- Multi-Scale Architecture
- Permutations & Channel Mixing
- Training & Architecture Details
- Limitations of Coupling Flows
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Derive NICE's additive coupling and show its volume-preserving property.
- Extend to RealNVP's affine coupling with learnable scaling.
- Explain Glow's invertible 1x1 convolution and LU decomposition.
- Design a multi-scale architecture with early factoring-out.
- Analyze why coupling flows require many layers for expressiveness.
Notation
- — split input
- — scale and translation networks (arbitrary)
- — invertible 1x1 convolution
Core Intuition
Coupling flows solve the expressiveness-tractability dilemma by splitting input into two halves: one half passes through unchanged (providing a "conditioner"), while the other half is transformed based on the first. This gives a triangular Jacobian (cheap determinant) while still allowing arbitrarily complex transformations. Stack many such layers, alternating which half is transformed.
Coupling Layer
NICE: Additive Coupling
NICE (Dinh et al., 2014): The simplest coupling:
where is any neural network (no constraints).
Inverse (trivial):
Jacobian:
Volume-preserving: always. The transformation cannot expand or contract regions — only shift them. Limited expressiveness without learned scaling.
RealNVP: Affine Coupling
RealNVP (Dinh et al., 2017): Add learnable scaling:
Inverse:
Log-determinant:
Key improvement over NICE: The scaling allows the model to expand/contract volumes — essential for modeling distributions with varying density.
Scale network : Outputs log-scale factors. No constraint on output range; ensures positivity.
Translation network : Shifts values. Combined with scaling: affine transformation of the second half, conditioned on the first.
Glow: 1x1 Convolutions
Problem: Coupling layers only transform half the dimensions per layer. Need to mix information between halves.
Glow (Kingma & Dhariwal, 2018): Replace fixed permutations with learned invertible 1x1 convolutions:
Log-determinant: for spatial dimensions .
LU decomposition for efficiency: Parameterize :
- : fixed permutation matrix.
- : lower triangular with ones on diagonal.
- : upper triangular.
Multi-Scale Architecture
Key design pattern: Factor out half the dimensions at each scale level:
- Level 1: Process at full resolution. After steps, split: (factored out) + remaining.
- Level 2: Squeeze (2x2 → channels). Process. Split: + remaining.
- Level L: Final level. All remaining dimensions become .
Final latent: .
Benefits:
- Early dimensions model coarse structure, later dimensions model fine details.
- Reduces computation (fewer dimensions at deeper levels).
- Improves training stability (gradients flow at multiple scales).
Each "step" consists of:
- ActNorm (learned batch normalization).
- Invertible 1x1 conv.
- Affine coupling layer.
Permutations & Channel Mixing
Why permutations matter: A coupling layer leaves unchanged. Without mixing, the same dimensions are always "frozen." After layers with the same split, half the dimensions have never been directly transformed.
Options (increasing quality):
- Fixed reversal: Alternate which half is frozen. Simplest.
- Fixed random permutation: Better mixing but still static.
- Learned 1x1 conv (Glow): Optimal mixing, adds minimal overhead.
Training & Architecture Details
Base distribution: Isotropic Gaussian .
Loss: Negative log-likelihood:
Coupling network architecture ():
- For images: 3-layer CNN with 512 channels (residual blocks).
- Separate networks for and , or shared with split output.
- NO constraint on (they don't need to be invertible).
Typical configuration (Glow on faces):
- 3 scale levels, steps per level.
- Total: 96 coupling layers + 96 1x1 convs + 96 ActNorms.
Limitations of Coupling Flows
- Expressiveness per layer: Only transforms half the dimensions → needs many layers.
- Topology: Cannot change the topology of the distribution (homeomorphism). Can't map disconnected regions to connected ones in finite layers.
- Sample quality: Inferior to diffusion models and GANs on image generation (FID scores typically 2-3x higher).
- Dimension mismatch: Input and output must have the same dimensionality (no compression).
Common Pitfalls
Pitfall 1. Using too few coupling layers. For CIFAR-10 (32x32x3 = 3072 dims): need at least 32 coupling layers for reasonable quality.
Pitfall 2. Not using ActNorm. Without proper normalization, the scale network can output extreme values early in training, causing numerical instability.
Pitfall 3. Forgetting to alternate the split pattern. Without alternation, half the dimensions are never directly transformed.
Summary
- NICE: Additive coupling; volume-preserving; limited expressiveness.
- RealNVP: Affine coupling; learned scaling; triangular Jacobian.
- Glow: LU-decomposed 1x1 conv for optimal channel mixing.
- Multi-scale: Factor out dimensions progressively; coarse-to-fine modeling.
- Training: Direct MLE; no adversarial loss, no reconstruction.
- Typical: 32-96 coupling layers for image generation.
Exercises
Exercise 1. Prove that two consecutive NICE layers with opposite splits can represent any invertible affine transformation.
Exercise 2. For a Glow model on 64x64x3 images with 4 levels and steps: count total parameters for coupling networks (assume 3-layer CNN with 512 channels each).
Exercise 3. Show that the multi-scale factored-out variables at the first level correspond to coarse image features.
Exercise 4. Derive the memory cost of storing all intermediate activations for a Glow model with levels and steps (needed for gradient computation).
Exercise 5. Compare the bits-per-dimension (BPD) achievable by Glow vs a VAE on CIFAR-10. Explain why exact likelihood doesn't always mean better generation.