Neural Spline Flows

Conor Durkan, Artur Bekasov, Iain Murray, George Papamakarios

TL;DR

Neural Spline Flows (NSF) introduce a highly flexible, fully differentiable, and analytically invertible transformation for normalizing flows based on monotonic rational-quadratic splines. By replacing simple affine transformations with these splines, the authors achieve state-of-the-art density estimation on tabular data and improve generative image modeling, all while maintaining the computational efficiency of coupling layers.

What Problem Does This Paper Address?

Normalizing flows are a class of generative models that map a simple probability distribution (like a Gaussian) to a complex one (like the distribution of natural images) using a sequence of invertible transformations. To be useful, these transformations must satisfy three difficult criteria:

  1. Invertibility: The model must easily go from noise to data (sampling) and data to noise (density evaluation).
  2. Tractable Jacobian: Calculating the "stretch" or "compression" of the transformation (the Jacobian determinant) must be computationally cheap.
  3. Flexibility: The transformation must be complex enough to capture the nuances of real-world data.

Existing methods often trade off these properties. Coupling layers (like RealNVP or Glow) are fast but rely on simple affine transformations ($y = ax + b$), which lack expressivity. Autoregressive flows are more flexible but are notoriously slow to sample from because they require a sequential loop over dimensions. Previous attempts to use splines were often numerically unstable or required iterative methods to invert.

Methods: Monotonic Rational-Quadratic Splines

The authors propose Monotonic Rational-Quadratic Splines as a "drop-in" replacement for the standard affine transformations used in flows.

A monotonic rational-quadratic spline transform and its highly flexible derivative.
  • The Spline: Instead of a single line ($ax+b$), the input space is divided into $K$ bins. Inside each bin, the transformation is a rational-quadratic function (a quotient of two quadratic polynomials).
  • Analytic Inversion: Because the function is rational-quadratic, inverting it simply requires solving a standard quadratic equation, which has a closed-form solution. This avoids the slow, iterative numerical methods required by previous spline-based flows.
  • Differentiability: The splines are constructed to be $C^1$ continuous (the function and its first derivative are continuous), making them easy to train with standard gradient descent.
  • The "Tails": To handle inputs outside a defined range $[-B, B]$, the authors use identity transformations (linear tails), allowing the model to process unconstrained data.

The paper introduces two main architectures: RQ-NSF (C), which uses these splines in coupling layers (fast sampling), and RQ-NSF (AR), which uses them in autoregressive layers.

Key Insights and Results

The authors evaluated their method across tabular data, variational inference, and image generation.

Closing the Gap: One of the most significant findings is that coupling layers can match the performance of autoregressive layers if the elementwise transformation is powerful enough. This is a huge win for practitioners who want the speed of coupling layers without sacrificing accuracy. Because splines can "wiggle" much more than a straight line, they naturally induce multi-modality in the transformed distribution, allowing the model to fit complex, disjoint clusters of data more easily.

Test log-likelihoods on tabular datasets, showing RQ-NSF achieving state-of-the-art results.
  • Tabular SOTA: RQ-NSF achieved state-of-the-art log-likelihood results on the Power, Gas, and Hepmass datasets compared to other normalizing flow methods like FFJORD, MAF, and NAF.
  • Parameter Efficiency in Images: On ImageNet $64 \times 64$ (8-bit), RQ-NSF (C) achieved a bits-per-dimension (BPD) of 3.82 using only 15.6M parameters, compared to Glow's 3.81 BPD which required a massive 110.9M parameters.
  • Qualitative Success: The model produced globally coherent and diverse image samples, demonstrating that the spline transformations don't just help with math—they help capture the structure of visual data.

Limitations and Future Work

While powerful, implementing rational-quadratic splines is significantly more involved than simple affine shifts (though the authors provided a reference PyTorch implementation). Furthermore, while the number of parameters is lower, the splines add a computational cost, with the authors noting a 30-40% increase in wall-clock time per training update compared to affine models. Future directions include exploring more powerful neural networks to parameterize the splines and investigating splines that offer higher-order continuity.

Summary updated

BibTeX
@inproceedings{durkan2019neural,
  author = {Conor Durkan and Artur Bekasov and Iain Murray and George Papamakarios},
  title = {{Neural Spline Flows}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
  url = {https://openreview.net/forum?id=VRBovC34Lox},
}
Figure