Training Energy-Based Models with Diffusion Contrastive Divergences

Weijian Luo, Hao Jiang, Tianyang Hu, Jiacheng Sun, Zhenguo Li, Zhihua ZhangarXiv 2023

Abstract

Energy-Based Models (EBMs) have been widely used for generative modeling. Contrastive Divergence (CD), a prevailing training objective for EBMs, requires sampling from the EBM with Markov Chain Monte Carlo methods (MCMCs), which leads to an irreconcilable trade-off between the computational burden and the validity of the CD. Running MCMCs till convergence is computationally intensive. On the other hand, short-run MCMC brings in an extra non-negligible parameter gradient term that is difficult to handle. In this paper, we provide a general interpretation of CD, viewing it as a special instance of our proposed Diffusion Contrastive Divergence (DCD) family. By replacing the Langevin dynamic used in CD with other EBM-parameter-free diffusion processes, we propose a more efficient divergence. We show that the proposed DCDs are both more computationally efficient than the CD and are not limited to a non-negligible gradient term. We conduct intensive experiments, including both synthesis data modeling and high-dimensional image denoising and generation, to show the advantages of the proposed DCDs. On the synthetic data learning and image denoising experiments, our proposed DCD outperforms CD by a large margin. In image generation experiments, the proposed DCD is capable of training an energy-based model for generating the Celab-A $32\times 32$ dataset, which is comparable to existing EBMs.

Introduction: The MCMC Bottleneck

Energy-Based Models (EBMs) represent probability distributions through a scalar energy function $E_\theta(x)$. While powerful, training them is challenging because the normalization constant is typically intractable. The standard training approach, Contrastive Divergence (CD), relies on Markov Chain Monte Carlo (MCMC) sampling to approximate the gradient of the log-likelihood.

This approach faces two primary issues:

  1. Computational Inefficiency: Reaching the stationary distribution via MCMC is slow.
  2. Gradient Bias: To save time, "short-run" MCMC is often used. However, this introduces a dependency where the samples themselves become functions of the model parameters $\theta$. Standard training ignores the resulting complex gradient term, leading to biased updates and potential instability.

Methodology: Diffusion Contrastive Divergence (DCD)

The authors introduce Diffusion Contrastive Divergence (DCD) to resolve these issues. The fundamental innovation is decoupling the sampling process from the model parameters. Instead of using Langevin Dynamics (which depends on the EBM's gradient $\nabla_x E_\theta(x)$), DCD utilizes a parameter-free diffusion process, such as Variance Exploding (VE) diffusion.

Comparison of CD and DCD frameworks

By evolving both the data and model distributions under a Stochastic Differential Equation (SDE) that does not depend on $\theta$, the problematic "non-negligible gradient term" is eliminated. Using the Fokker-Planck equation, the authors derive a training objective that requires only the energy function and its derivatives (specifically the Laplacian), avoiding sequential MCMC steps in the inner training loop. This framework provides a unified view, showing that CD is a specific instance of DCD where the diffusion process is tied to the model's own energy landscape.

Key Results and Insights

The DCD framework was validated across synthetic 2D datasets, image denoising tasks, and high-dimensional image generation.

  • Superior 2D Modeling: DCD-VE successfully learned complex topologies like the Swissroll and Rings, where traditional CD and Persistent CD (PCD) often fail to converge or capture the global structure.
  • Efficiency: DCD achieved a 2-4x wall-clock speedup over traditional CD by replacing slow MCMC chains with efficient noise-based sampling.
  • Robustness: In image denoising, DCD-VE remained effective even at high noise levels where CD-trained models failed completely.
  • Generative Quality: On the CelebA $32\times 32$ dataset, DCD achieved an FID score of 13.85, demonstrating that it can scale to high-dimensional data while maintaining a simpler training loop.
Performance comparison on synthetic data and CelebA

Discussion and Limitations

While DCD offers significant speed and stability advantages, it introduces new computational requirements. The objective involves calculating the Laplacian of the energy function. Although this is managed using Hutchinson’s trace estimator, it requires the model to be twice differentiable and increases GPU memory usage compared to standard MCMC. Future work may focus on extending DCD to longer diffusion time horizons and further optimizing the memory footprint of the trace estimation.

Summary updated

BibTeX
@misc{luo2023training,
  author = {Weijian Luo and Hao Jiang and Tianyang Hu and Jiacheng Sun and Zhenguo Li and Zhihua Zhang},
  title = {{Training Energy-Based Models with Diffusion Contrastive Divergences}},
  year = {2023},
  eprint = {2307.01668},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.01668},
}
Figure