MCMC Should Mix: Learning Energy-Based Model with Neural Transport Latent Space MCMC

Erik Nijkamp, Ruiqi Gao, Pavel Sountsov, Srinivas Vasudevan, Bo Pang, Song-Chun Zhu, Ying Nian WuICLR 2022

TL;DR

Training Energy-Based Models (EBMs) often fails because the sampling process gets "stuck" in local modes, leading to biased learning. This paper introduces Neural Transport EBM (NT-EBM), which performs MCMC sampling in the smooth latent space of a flow-based model. This allows the sampler to traverse different data modes freely, enabling more stable and mathematically sound model learning.

The Mixing Problem in EBMs

Energy-Based Models (EBMs) are a powerful class of generative models that define a probability distribution through an unnormalized energy function. To learn this function, researchers typically use an "Analysis by Synthesis" approach: generating samples from the current model using Markov Chain Monte Carlo (MCMC) and comparing them to real data.

The "Achilles' heel" of this approach is mixing. In high-dimensional spaces like images, the energy landscape is incredibly rugged and multi-modal. Standard MCMC methods, such as Langevin dynamics, tend to get trapped in the first local mode they encounter. If the MCMC doesn't "mix"—meaning it fails to visit all the different modes of the distribution—the gradients used to update the model become highly biased. This often results in models that generate visually appealing samples in the short term but rest on mathematically shaky ground.

Neural Transport EBM (NT-EBM)

To overcome the mixing problem, the authors propose a hybrid approach called Neural Transport EBM (NT-EBM). Instead of building an EBM from scratch in the raw pixel space, they utilize a pre-trained flow-based model (like Glow) as a backbone.

1. Exponential Tilting

The EBM is defined as a "correction" or "tilting" of the flow model. If the flow model provides a rough approximation of the data distribution, the EBM's role is to refine it.

2. Latent Space MCMC

The key innovation lies in where the sampling takes place. Because flow models are invertible, every image $x$ has a corresponding latent code $z$. While the distribution of $x$ is complex and multi-modal, the distribution of $z$ is designed to approximate a simple Gaussian.

Latent space MCMC enables chains to traverse isolated modes in the data space.

3. The Jacobian Shortcut

Mathematically, performing MCMC in the latent space of a flow model to sample from this "tilted" distribution causes the complex Jacobian determinants—which usually make flow models computationally heavy—to cancel out. This leaves a remarkably simple energy function in the latent space that is much easier for Hamiltonian Monte Carlo (HMC) to navigate.

By sampling in $z$-space and then "pushing" those samples through the flow model back to $x$-space, the Markov chains can jump between distant modes (e.g., from a "2" to a "7" in MNIST) much more easily than they could by walking directly through pixel space.

Experimental Insights and Results

The researchers evaluated NT-EBM on four standard image benchmarks: MNIST, SVHN, CIFAR-10, and CelebA.

Rigorous Mixing Diagnostics

Unlike many deep learning papers that rely solely on visual quality, this study employs the Gelman-Rubin statistic ($\hat{R}$). This rigorous statistical tool measures whether multiple MCMC chains have converged to the same distribution. The authors show that NT-EBM achieves $\hat{R} < 1.2$, indicating true convergence, whereas standard pixel-space EBMs fail miserably on this metric.

Improved Synthesis and Mode Traversal

On all tested datasets, the NT-EBM significantly outperformed the base flow model (Glow) in terms of FID scores, which measure image quality and diversity. For example, on MNIST, Glow achieved an FID of 66.04, while NT-EBM improved it dramatically to 21.32.

Qualitative results demonstrate a single Markov chain successfully transitioning between different digits or facial identities. In contrast, standard EBMs usually remain stuck on a single "blurry" version of one object for thousands of steps. Furthermore, the authors demonstrated that a "medium-sized" flow model corrected by an EBM could outperform a much larger standalone flow model, suggesting that EBM corrections are a highly parameter-efficient way to improve generative models.

Limitations and Future Directions

While NT-EBM represents a massive improvement over base flow models and standard EBMs, its absolute image quality (FID) still trails behind state-of-the-art Diffusion models or GANs. The authors acknowledge this "subpar quality" and hope to address it by integrating better flow architectures.

Additionally, in this paper, the flow model is pre-trained and fixed. Jointly training the flow backbone and the EBM correction could lead to even stronger results. Ultimately, the authors believe that having an EBM that genuinely mixes will be crucial for downstream tasks beyond image synthesis, such as out-of-distribution detection and robust feature learning.

Summary updated

BibTeX
@inproceedings{nijkamp2022mcmc,
  author = {Erik Nijkamp and Ruiqi Gao and Pavel Sountsov and Srinivas Vasudevan and Bo Pang and Song-Chun Zhu and Ying Nian Wu},
  title = {{MCMC Should Mix: Learning Energy-Based Model with Neural Transport Latent Space MCMC}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=9PgTvyrl6f5},
}
Figure