Abstract: Energy-based models are a simple yet powerful class of probabilistic models, but their widespread adoption has been limited by the computational burden of training them. We propose a novel loss function called Energy Discrepancy (ED) which does not rely on the computation of scores or expensive Markov chain Monte Carlo. We show that ED approaches the explicit score matching and negative log-likelihood loss under different limits, effectively interpolating between both. Consequently, minimum ED estimation overcomes the problem of nearsightedness encountered in score-based estimation methods, while also enjoying theoretical guarantees. Through numerical experiments, we demonstrate that ED learns low-dimensional data distributions faster and more accurately than explicit score matching or contrastive divergence. For high-dimensional image data, we describe how the manifold hypothesis puts limitations on our approach and demonstrate the effectiveness of energy discrepancy by training the energy-based model as a prior of a variational decoder model.
Introduction
Energy-Based Models (EBMs) represent probability distributions through a scalar energy function $E(x)$, where the probability density is defined as $p(x) \propto \exp(-E(x))$. While mathematically elegant, EBMs are notoriously difficult to train because they require calculating an intractable partition function—the integral over the entire data space.
Traditionally, researchers have relied on two primary strategies to bypass this:
- Contrastive Divergence (CD): This uses Markov chain Monte Carlo (MCMC) to approximate the gradient of the log-likelihood. However, MCMC is computationally expensive and often unstable.
- Score Matching (SM): This matches the gradient of the model's log-density to the data. While MCMC-free, SM is "nearsighted," meaning it only captures local slopes and struggles to learn the relative weights between distant modes in a distribution.
This paper introduces Energy Discrepancy (ED), a loss function designed to be the "Goldilocks" solution: MCMC-free like score matching, yet globally aware like maximum likelihood estimation.
The Energy Discrepancy Framework
The core of the ED objective is contrastive. It compares the energy of a real data point $x$ to the energy of a perturbed version $y$, created by adding noise through a diffusion process. By viewing this perturbation as a Gaussian blurring process, the authors demonstrate that the ED loss effectively integrates score matching objectives across multiple noise scales.
Bridging the Gap
A significant theoretical contribution of this work is proving that ED acts as a bridge between existing methods. In the limit of infinitesimal noise, ED recovers the Score Matching objective. Conversely, in the limit of infinite noise, it approaches the Maximum Likelihood objective. This interpolation allows ED to capture both fine-grained local details and the global structure of the data distribution.
Numerical Stability via $w$-stabilization
To make ED practical, the authors introduce $w$-stabilization. Approximating the loss using Monte Carlo samples involves the logarithm of an expectation, which is prone to numerical instability. By adding a weighting term ($w$) that incorporates the energy of the original data point, the authors create a "soft-min" operation. This stabilization prevents gradient explosion and allows the model to train effectively even with a very small number of noise samples ($M$), significantly reducing computational overhead.
Experimental Results
The authors evaluated ED across synthetic 2D distributions, image datasets (SVHN, CIFAR-10, CelebA), and anomaly detection tasks.
2D Synthetic Distributions
On complex 2D tasks such as the "25-Gaussians" and "Pinwheel" patterns, ED converged faster and achieved lower Mean Squared Error (MSE) than both Score Matching and Contrastive Divergence. Crucially, ED successfully "healed" the nearsightedness of SM, correctly capturing the weights of all 25 modes where SM failed.
Latent EBMs for High-Dimensional Data
Directly training EBMs on high-dimensional pixel space is challenged by the Manifold Hypothesis, which suggests data lives on low-dimensional surfaces. To address this, the authors trained ED as a Latent EBM (LEBM), applying the energy function to the features of a variational autoencoder.
- Image Generation: On SVHN and CelebA, ED-LEBM outperformed previous benchmarks in both reconstruction quality and generation (FID scores). On SVHN, it achieved an FID of 28.10, surpassing the previous CD-based state-of-the-art of 29.44.
- Anomaly Detection: In MNIST "leave-one-out" protocols, ED-LEBM consistently outperformed VAEs and other EBM variants in identifying out-of-distribution samples, achieving higher AUPRC scores.
Conclusion and Future Work
Energy Discrepancy offers a robust, score-independent alternative for training EBMs without the computational burden of MCMC. By providing a theoretical link between score matching and maximum likelihood, it offers a more holistic approach to density estimation. While the manifold hypothesis remains a constraint for raw pixel-space training, the success of ED in latent spaces suggests it is a powerful tool for complex generative modeling. Future research may explore alternative noise distributions and applications to discrete data structures like graphs or molecular manifolds.
Summary updated