Piecewise Normalizing Flows

Harry Bevins, Will Handley · DOI

TL;DR

This paper introduces "piecewise normalizing flows" (PNFs) to better model complex, multi-modal probability distributions. By first clustering the target distribution and then training individual normalizing flows on each cluster, PNFs achieve higher accuracy and are more computationally efficient than existing methods, especially when trained in parallel.

What Problem Does This Paper Address?

Normalizing flows (NFs) are powerful tools for learning probability distributions by transforming a simple base distribution (like a standard Gaussian) into a complex target distribution. However, NFs rely on a bijective mapping, which can struggle when the target distribution has a complex topology, particularly when it's multi-modal (has multiple distinct peaks). This mismatch in topology can lead to NFs creating artificial "bridges" between modes, reducing accuracy. Existing solutions often involve modifying the base distribution or using complex sampling strategies, which can be computationally expensive or less effective. This paper tackles the challenge of accurately and efficiently modeling multi-modal distributions with normalizing flows.

Methods

The core innovation is the piecewise normalizing flow (PNF). The process involves:

  1. Clustering: The target distribution's samples are first divided into clusters using an algorithm like k-means. The optimal number of clusters is determined using the silhouette score.
  2. Piecewise Training: For each cluster, a separate normalizing flow (specifically, Masked Autoregressive Flows or MAFs) is trained. Each MAF uses a standard Gaussian as its base distribution. This effectively makes the topology of each piece of the target distribution more similar to the simple Gaussian base.
  3. Sampling: When generating samples from the PNF, a cluster is chosen based on the total weight of samples within that cluster, and then a sample is drawn from the corresponding MAF.

This approach leverages the fact that each individual cluster is a simpler distribution than the overall multi-modal target, making it easier for a standard NF to model. The paper also highlights that the training of these individual MAFs can be parallelized, leading to significant computational gains.

Datasets

The paper evaluates its approach on:

  • Toy Models: Standard multi-modal distributions like "Two Moons," "Circle of Gaussians," and "Two Rings." These are used to demonstrate the effectiveness of the PNF in capturing complex shapes.
  • UCI Machine Learning Repository Datasets: Specifically, POWER, GAS, HEPMASS, and MINIBOONE. These are used to assess the performance on real-world data, though the paper notes these datasets are not necessarily strongly multi-modal.

Key Insights and Ideas

  • Topology Mismatch is Key: The paper strongly emphasizes that the difficulty NFs face with multi-modal distributions stems from the topological difference between the simple base distribution and the complex target.
  • Divide and Conquer for Topology: By clustering the target distribution, the PNF effectively "breaks down" the complex topology into simpler pieces, each of which can be more easily mapped from a standard Gaussian.
  • Parallelization for Efficiency: The ability to train individual MAFs for each cluster in parallel is a significant advantage, leading to reduced training time and computational cost compared to training a single, large NF.
  • Clustering Algorithm Matters: While k-means was found to be the best performing clustering algorithm for this task, the paper shows that PNFs can be built with various clustering methods, suggesting flexibility.

Key Results

  • Improved Accuracy: PNFs consistently outperform the approach from Stimper et al. (2022) (which uses a resampled base distribution) in terms of emulation accuracy on standard multi-modal benchmarks, achieving higher accuracy with a smaller error (indicating more consistent results).
  • Computational Efficiency: While the RealNVP method from Stimper et al. has the shortest wall-clock time when trained serially, the PNF's cost (defined as epochs * data size * hyperparameters) is significantly lower due to fewer hyperparameters per MAF and the potential for parallelization. When parallelized, the PNF's wall-clock time can become competitive.
  • Clustering Performance: k-means was identified as the best clustering algorithm, but Mean Shift and Birch clustering also showed competitive results.

Limitations and Future Work

  • Differentiability: The PNF approach is differentiable as long as the clustering algorithm used is differentiable and the number of clusters is fixed during training.
  • Bijectivity: The PNF is bijective if the cluster assignment is known. The paper proposes a way to handle this by considering the cluster number as part of the output space.
  • Clustering Algorithm Choice: While k-means performed best, the paper acknowledges that the optimal clustering algorithm might be data-dependent. Future work could explore more advanced clustering techniques or adaptive methods for determining the number of clusters.
  • Non-Multi-modal Data: For datasets that are not strongly multi-modal, a single MAF might perform better or comparably to a PNF, as seen in the UCI dataset results. The PNF's advantage is most pronounced for truly multi-modal distributions.

Summary updated

BibTeX
@misc{bevins2023piecewise,
  author = {Harry Bevins and Will Handley},
  title = {{Piecewise Normalizing Flows}},
  year = {2023},
  eprint = {2305.02930},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.02930},
}
Figure