EBMs Trained with Maximum Likelihood are Generator Models Trained with a Self-adverserial Loss

Zhisheng Xiao, Qing Yan, Yali Amit

Abstract

Energy-Based Models (EBMs) are traditionally viewed as likelihood-based models trained via MCMC sampling. This paper challenges this perspective, arguing that in practice, EBM training is a self-adversarial procedure where the model acts as both a generator and a critic. By replacing stochastic sampling with deterministic gradient descent, we demonstrate that EBMs are essentially generator models in disguise, leading to more stable training and significantly improved image quality.

Introduction: The Gap Between Theory and Practice

The standard approach to training an EBM involves Maximum Likelihood Estimation (MLE), which requires drawing samples from the model using Markov Chain Monte Carlo (MCMC) methods like Langevin Dynamics. However, a significant gap exists between theoretical requirements and practical implementation:

  1. The Convergence Gap: Theory requires MCMC to converge to the model's distribution, which is computationally prohibitive in high dimensions. Practitioners often rely on "short-run" dynamics.
  2. The Noise Paradox: While Langevin Dynamics includes a noise term, empirical evidence suggests that reducing this noise to near zero often yields better results.
  3. The Density Mismatch: EBMs frequently produce high-quality samples even when their mathematical density function fails to represent the data distribution accurately.

This research investigates why EBMs succeed despite these theoretical discrepancies.

Methodology: EBMs as Deterministic Generators

We propose shifting the perspective of EBM training by treating the sampling process as a deterministic generator.

Noise-Free Dynamics

By replacing stochastic Langevin SDEs with a noise-free gradient descent ODE ($x'(t) = -\nabla_x E_\theta(x(t))$), the sampling process becomes a deterministic transformation of initial noise into data. Under mild conditions, this ODE is invertible, allowing the sampling process to be viewed as a continuous normalizing flow. This enables the explicit calculation of the density induced by the dynamics (the flow) rather than just the density defined by the energy function.

Self-Adversarial Loss

Mathematically, the EBM training objective mirrors a Wasserstein GAN (W-GAN). In this framework, the energy function $E$ serves as the critic, while the gradient of that same energy function defines the generator. To capitalize on this, we introduce an additional "generator loss" term to the objective, explicitly optimizing the quality of samples produced by the gradient flow.

Key Insights: The Flow Density vs. Energy Density

A critical finding on toy datasets (Swiss Roll and 9-Gaussian grid) is that the EBM's energy function often fails to capture the true data manifold. However, the density induced by the gradient flow matches the data perfectly. This suggests that the "flow" is the primary generative mechanism being trained, not the static energy function.

Comparison of data, samples, energy density, and flow density on Swiss Roll and 9-Gaussian datasets. Note how the flow density (rightmost) captures the data structure far better than the energy density (second from right).

Furthermore, removing noise improves training stability. Contrary to the belief that MCMC noise is necessary for exploration, noise-free dynamics are less prone to divergence and produce sharper samples.

Quantitative Results

The transition to noise-free dynamics and the inclusion of an explicit generator loss yielded substantial improvements in Fréchet Inception Distance (FID) across multiple benchmarks.

Model / Dataset MNIST Fashion-MNIST CIFAR-10 CelebA
EBM w/ noisy dynamics 15.4 61.7 70.4 69.6
EBM w/ noise-free dynamics 11.7 50.1 61.6 56.6
+ Generator Loss 7.7 40.6 47.9 34.8

Qualitatively, samples from the noise-free models with generator loss are significantly sharper and more recognizable, particularly on complex datasets like CelebA.

Conclusion and Future Work

This work bridges the gap between EBMs and GANs, suggesting that EBM training is effectively a self-adversarial game. While challenges remain regarding the practical invertibility of the ODE at large step sizes, the results indicate that researchers should prioritize improving training techniques that treat sampling dynamics as the primary generative mechanism. Future work will explore the trade-offs between generator performance and the mathematical properties of the underlying energy function.

Summary updated

BibTeX
@inproceedings{xiao2021ebms,
  author = {Zhisheng Xiao and Qing Yan and Yali Amit},
  title = {{EBMs Trained with Maximum Likelihood are Generator Models Trained with a Self-adverserial Loss}},
  booktitle = {EBM @ ICLR},
  year = {2021},
  url = {https://openreview.net/forum?id=osPDkDQXgI7},
}
Figure