Generalized Normalizing Flows via Markov Chains

Paul Hagemann, Johannes Hertrich, Gabriele SteidlCambridge 2023 · DOI · OpenAlex

TL;DR

This paper introduces a "Grand Unified Theory" for generative modeling by framing Normalizing Flows (NFs), Variational Autoencoders (VAEs), and Diffusion models as pairs of Markov chains. By replacing deterministic invertible layers with stochastic Markov kernels, the authors create Stochastic Normalizing Flows (SNFs), which overcome the topological limitations of standard flows and can represent complex, multimodal distributions far more effectively.

What Problem Does This Paper Address?

Standard Normalizing Flows are powerful because they are explicitly invertible, allowing for exact likelihood computation. However, they live in a "topological straightjacket." Because they rely on continuous diffeomorphisms (smooth, invertible mappings), they struggle to map a simple unimodal distribution (like a Gaussian "blob") to a multimodal distribution (multiple disconnected "blobs").

To bridge these gaps, standard flows often "smear" probability mass between modes, creating artificial bridges where none should exist. Furthermore, the inverse of such a flow often requires an infinitely large Lipschitz constant to achieve a perfect match. The authors aim to break these constraints by injecting stochasticity—randomness—directly into the flow's architecture.

Methods

The core innovation is viewing the generative process as a Markov chain.

  • The Framework: Instead of a single invertible function $T$, the authors define a forward Markov chain (moving from data to noise) and a reverse Markov chain (moving from noise to data).
  • Stochastic Layers: The paper mathematically integrates several stochastic techniques into the flow:
  • Langevin & MALA Layers: Use gradient information to "push" samples toward high-density regions.
  • Metropolis-Hastings (MH) Layers: Use an accept/reject step to prune samples from low-probability areas, effectively "jumping" between modes.
  • VAE Layers: The authors prove that a VAE is essentially a special case of a one-layer SNF.
  • Diffusion Layers: These are treated as discretizations of Stochastic Differential Equations (SDEs).
  • The Loss Function: They derive a unified loss function ($L_{SNF}$) based on the Kullback–Leibler (KL) divergence of the joint distributions of the Markov chains. This provides a mathematically sound way to train deterministic and stochastic layers simultaneously.

Datasets

The paper focuses on benchmarking the framework across three main scenarios:

  1. 2D Energy Modeling: Synthetic "Smiley face" densities used to visualize how stochastic steps prevent "smearing" between features.
  2. High-Dimensional Gaussian Mixtures: A challenging 100-dimensional academic problem with analytical ground truth, used to compare different combinations of layers (INN, VAE, MALA).
  3. Scatterometry: A real-world inverse problem from physics/engineering involving the determination of photo mask structures from light diffraction patterns.

Key Insights and Ideas

  • Probabilistic Invertibility: We don't need a function to be strictly invertible in the algebraic sense ($x = f^{-1}(y)$). We only need a reverse Markov kernel that "undoes" the forward step in a probabilistic sense.
  • Stochasticity as a Mode-Separator: Deterministic flows are "stuck" with the topology they start with. Stochastic layers (like MH) allow the model to "delete" samples in low-density regions, allowing for the creation of truly disconnected modes.
  • Unification: The realization that VAEs, Diffusion models, and NFs aren't just related—they are mathematically subsumed under the Markov chain framework—allows researchers to mix and match these components like LEGO bricks.

Key Results

  • Expressivity Boost: In the 2D "Smiley" tests, standard Invertible Neural Networks (INNs) produced blurry, smeared results. In contrast, SNFs with MH layers recovered sharp, concentrated densities.
  • Quantitative Superiority: In the 100D Gaussian Mixture experiment, the combination of INN + VAE + MALA achieved the lowest Wasserstein-1 distance (0.82) compared to a pure INN (2.12) or a pure VAE (1.73).
  • Inverse Problem Success: In the scatterometry task, the "Full Flow" (alternating INN, VAE, and MALA layers) provided the most accurate posterior distribution, effectively capturing the multimodal nature of the physical parameters.

Limitations and Future Work

  • Computational Overhead: Adding stochasticity isn't free. Using MALA or MH layers can increase training and inference time significantly (up to 8x slower than a plain VAE in some tests).
  • Gradient Challenges: The acceptance-rejection step in MCMC is non-differentiable. While the authors use specific derivations to handle this, getting unbiased gradient estimates remains a complex area of active research.
  • Path Learning: The authors note it isn't always clear when it is better to learn the entire "path" of the distribution (as in Diffusion) versus just optimizing the final state. Future work could explore more efficient "shortcuts" through the Markov chain.

Summary updated

Abstract

Normalizing flows, diffusion normalizing flows and variational autoencoders are powerful generative models. This Element provides a unified framework to handle these approaches via Markov chains. The authors consider stochastic normalizing flows as a pair of Markov chains fulfilling some properties, and show how many state-of-the-art models for data generation fit into this framework. Indeed numerical simulations show that including stochastic layers improves the expressivity of the network and allows for generating multimodal distributions from unimodal ones. The Markov chains point of view enables the coupling of both deterministic layers as invertible neural networks and stochastic layers as Metropolis-Hasting layers, Langevin layers, variational autoencoders and diffusion normalizing flows in a mathematically sound way. The authors' framework establishes a useful mathematical tool to combine the various approaches.
BibTeX
@inproceedings{hagemann2023generalized,
  author = {Paul Hagemann and Johannes Hertrich and Gabriele Steidl},
  title = {{Generalized Normalizing Flows via Markov Chains}},
  booktitle = {Cambridge},
  year = {2023},
  doi = {10.1017/9781009331012},
}

Loading related content...

Figure