Abstract
Normalizing flows are invertible neural networks with tractable change-of-volume terms, which allow optimization of their parameters to be efficiently performed via maximum likelihood. However, data of interest are typically assumed to live in some (often unknown) low-dimensional manifold embedded in a high-dimensional ambient space. The result is a modelling mismatch since -- by construction -- the invertibility requirement implies high-dimensional support of the learned distribution. Injective flows, mappings from low- to high-dimensional spaces, aim to fix this discrepancy by learning distributions on manifolds, but the resulting volume-change term becomes more challenging to evaluate. Current approaches either avoid computing this term entirely using various heuristics, or assume the manifold is known beforehand and therefore are not widely applicable. Instead, we propose two methods to tractably calculate the gradient of this term with respect to the parameters of the model, relying on careful use of automatic differentiation and techniques from numerical linear algebra. Both approaches perform end-to-end nonlinear manifold learning and density estimation for data projected onto this manifold. We study the trade-offs between our proposed methods, empirically verify that we outperform approaches ignoring the volume-change term by more accurately learning manifolds and the corresponding distributions on them, and show promising results on out-of-distribution detection.
Introduction
Most generative models, specifically standard Normalizing Flows (NFs), assume that data occupies the entire high-dimensional ambient space ($\mathbb{R}^D$). However, the manifold hypothesis suggests that real-world data—such as images or physical sensor readings—actually concentrates on a much lower-dimensional surface or manifold ($\mathbb{R}^d$, where $d < D$).
Standard "square" flows are forced to assign density to the entire $D$-dimensional space, creating a fundamental modeling mismatch. While "injective flows" (mappings from low to high dimensions) can theoretically address this, they introduce a significant computational challenge: the volume-change term. Calculating the determinant of the Jacobian-transpose-Jacobian ($J^T J$) is traditionally too expensive for high-dimensional data, leading previous research to either ignore it or rely on unreliable heuristics.
Rectangular Normalizing Flows (RNFs)
To bridge this gap, we introduce Rectangular Normalizing Flows (RNFs). RNFs enable end-to-end maximum likelihood training that simultaneously learns the manifold's geometry and the data distribution upon it. The core innovation lies in two novel, tractable methods to calculate the gradients of the volume-change term:
- The Exact Method: This approach utilizes forward-mode automatic differentiation (AD) to explicitly construct the Jacobian matrix. While more memory-intensive, it provides exact gradients for the optimization process.
- The Stochastic Method: By combining Conjugate Gradients (CG) and Hutchinson’s trace estimator, this method produces unbiased stochastic estimates of the gradient. It is significantly more memory-efficient, allowing the model to scale to ambient dimensions as high as $D \approx 3,000$.
To ensure the model accurately identifies the manifold, we optimize a Lagrangian objective. This maximizes the log-likelihood of the data on the manifold while constrained by a reconstruction error term, ensuring the data points effectively "sit" on the learned surface.
Experimental Evaluation
We evaluated RNFs across simulated, tabular, and image datasets. A key finding is that the volume-change term is essential for accurate modeling. As shown in Figure 1, ignoring this term (the "two-step" approach, RNFs-TS) leads to poor density estimation; the model may find the correct manifold shape but incorrectly "stretches" or "compresses" the distribution across it.
Tabular and Image Results
On standard tabular benchmarks such as POWER and GAS, the proposed RNFs-ML consistently outperformed the two-step baseline. Quantitative results in Figure 3 demonstrate the superior performance of our end-to-end maximum likelihood approach.
In image generation tasks (MNIST and Fashion-MNIST), RNFs achieved significantly better FID scores than baselines. Furthermore, RNFs show state-of-the-art performance in Out-of-Distribution (OoD) detection. By correctly specifying the dimensionality, a Rectangular Flow trained on Fashion-MNIST can distinguish it from MNIST digits with up to 98% accuracy—a task where standard square flows often fail by assigning higher likelihoods to simpler, unrelated data.
Discussion and Limitations
While RNFs provide a powerful framework for manifold learning, some challenges remain. The current method is primarily suited for manifolds homeomorphic to Euclidean space, making it difficult to learn disconnected clusters (like all 10 MNIST digits) as a single manifold. Additionally, the iterative nature of the Conjugate Gradient solver introduces computational overhead and potential numerical stability issues if the manifold is poorly conditioned. Future work will focus on improving preconditioning techniques and expanding the topological flexibility of the learned manifolds.
Summary updated