Resampling Base Distributions of Normalizing Flows

Vincent Stimper, Bernhard Schölkopf, José Miguel Hernández-Lobato

Abstract

Normalizing flows are a popular class of models for approximating probability distributions. However, their invertible nature limits their ability to model target distributions whose support have a complex topological structure, such as Boltzmann distributions. Several procedures have been proposed to solve this problem but many of them sacrifice invertibility and, thereby, tractability of the log-likelihood as well as other desirable properties. To address these limitations, we introduce a base distribution for normalizing flows based on learned rejection sampling, allowing the resulting normalizing flow to model complicated distributions without giving up bijectivity. Furthermore, we develop suitable learning algorithms using both maximizing the log-likelihood and the optimization of the Kullback-Leibler divergence, and apply them to various sample problems, i.e. approximating 2D densities, density estimation of tabular data, image generation, and modeling Boltzmann distributions. In these experiments our method is competitive with or outperforms the baselines.

Introduction: The Topological Constraint of Normalizing Flows

Normalizing flows (NFs) transform a simple base distribution (typically a standard Gaussian) into a complex target distribution through a series of invertible, differentiable mappings. While bijectivity ensures exact likelihood computation and efficient sampling, it imposes a significant topological constraint: the mapping must be a homeomorphism. This means the flow cannot change the number of connected components in the distribution's support.

When the target distribution is multimodal or has a complex topology—such as the "dual moon" or "circle of Gaussians" datasets—a standard NF starting from a single Gaussian blob is forced to stretch that blob to cover all modes. This creates "density filaments"—thin streaks of high probability in regions where no data exists. These filaments lead to unstable training, exploding gradients, and poor density estimation.

Methods: Learned Accept/Reject Sampling (LARS)

We propose a division of labor between the base distribution and the flow. Instead of requiring the flow to handle all geometric and topological complexity, we introduce a resampled base distribution that handles the "coarse" topology (e.g., the number of modes).

The resampled base is defined as: $$p(z) = \frac{1}{Z} \pi(z)a_\phi(z)$$ where $\pi(z)$ is a simple proposal distribution (like a Gaussian), $a_\phi(z) \in [0, 1]$ is a learned acceptance function, and $Z$ is a normalization constant. This allows the model to "carve out" the base distribution to match the target's topology while maintaining perfect invertibility in the flow layers.

To ensure efficiency, we use a truncation parameter $T$ for the rejection sampler. If the first $T-1$ samples are rejected, the $T$-th sample is accepted automatically. We also derived a new gradient estimator for the Kullback-Leibler (KL) divergence to allow joint training of the flow and the acceptance function.

Scaling to High Dimensions

Rejection sampling typically suffers from the "curse of dimensionality." To apply this method to high-dimensional data like images (e.g., CIFAR-10), we integrate the resampled base into multiscale architectures like Glow. We factorize the base distribution into smaller groups of dimensions (e.g., per channel) and apply resampling to these manageable factors independently.

Factorization of the base distribution into smaller groups of dimensions (e.g., per channel) to overcome the curse of dimensionality in high-dimensional settings.

Experimental Results

The method was evaluated across synthetic 2D densities, UCI tabular data, image generation, and molecular physics.

Synthetic 2D Densities

In 2D experiments, the resampled base completely eliminated the "filaments" between modes that plagued standard Gaussian and even Mixture-of-Gaussian (GMM) bases. By allowing the base distribution to be multimodal, the flow no longer needs to bridge disconnected regions with spurious probability mass.

Comparison of density estimation for synthetic 2D targets. The resampled base (RBD) eliminates the "filaments" between modes seen in standard Gaussian and GMM bases.

Tabular and Molecular Modeling

On UCI tabular benchmarks, the Resampled Base Normalizing Flow (RBD-NSF) outperformed or matched state-of-the-art Neural Spline Flows (NSF) across all datasets. In the domain of molecular physics, we modeled the Boltzmann distribution of Alanine dipeptide. The resampled model was the only one capable of accurately capturing the multimodal nature of the molecule's dihedral angles, significantly outperforming deep standard flows.

Conclusion

By introducing a resampled base distribution via learned rejection sampling, we enable normalizing flows to model complex topologies without sacrificing bijectivity. This approach effectively eliminates density filaments and improves performance across a wide range of tasks, from synthetic density estimation to complex molecular modeling, with minimal computational overhead.

Summary updated

BibTeX
@inproceedings{stimper2022resampling,
  author = {Vincent Stimper and Bernhard Schölkopf and José Miguel Hernández-Lobato},
  title = {{Resampling Base Distributions of Normalizing Flows}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2022},
  url = {https://openreview.net/forum?id=FAFWTnz49zM},
}
Figure