Variational (Gradient) Estimate of the Score Function in Energy-based Latent Variable Models

Fan Bao, Kun Xu, Chongxuan Li, Lanqing Hong, Jun Zhu, Bo Zhang

Introduction

Energy-Based Models (EBMs) are highly expressive tools for modeling complex data distributions. However, they are notoriously difficult to train because calculating their "partition function"—the normalization constant—is usually intractable. Score Matching (SM) offers a workaround by focusing on the "score function" (the gradient of the log-density with respect to the input), bypassing the partition function entirely.

A major challenge arises when introducing latent variables to create Energy-Based Latent Variable Models (EBLVMs). In these models, the score function becomes an integral over the latent space, making it intractable for general architectures. Previous solutions, such as Bi-level Score Matching (BiSM), function well but suffer from high memory and time costs due to gradient unrolling. This paper introduces VaES and VaGES, two novel variational techniques for estimating the score function and its parameter gradients, enabling efficient, score-based learning for complex EBLVMs without restrictive structural assumptions.

Methodology: Variational Score Estimation

The authors observe that the score function and its gradient with respect to model parameters can be expressed as expectations and covariances over the posterior distribution of the latent variables. To handle the intractability of the true posterior, they propose a four-step approach:

  1. Amortized Variational Inference: A variational posterior $q_\phi(h|v)$ is introduced to approximate the true posterior $p_\theta(h|v)$.
  2. VaES (Variational Estimate of the Score): A Monte Carlo estimate of the score function is computed using samples drawn from the variational posterior.
  3. VaGES (Variational Gradient Estimate of the Score): An estimate for the gradient of the score is formulated by combining Monte Carlo sampling for the expectation term and a sample covariance matrix for the covariance term.
  4. Langevin Dynamics Corrector: To improve the quality of the variational samples, the authors optionally run a few steps of Langevin dynamics, "correcting" the samples toward the true posterior.

Key Insights & Theoretical Guarantees

A foundational contribution of this work is its theoretical rigor regarding estimation bias. The authors prove that the bias of both VaES and VaGES is linearly proportional to the square root of the divergence (KL or Fisher) between the variational and true posterior.

Numerical validation showing bias is proportional to the square root of the divergence.

Beyond theoretical guarantees, the approach offers significant practical advantages:

  • Efficiency over Unrolling: Unlike BiSM, which requires unrolling optimization steps and consumes massive memory, VaES/VaGES relies on a standard variational approach. This makes it significantly faster and more memory-efficient.
  • The Covariance Term: Explicitly handling the covariance term in the score gradient via sample covariance allows VaGES to generalize across various EBLVM architectures.
  • Versatility: These estimates can be seamlessly integrated into Kernelized Stein Discrepancy (KSD), standard Score Matching, and exact Fisher Divergence evaluations.

Empirical Results

The researchers evaluated their methods across synthetic data, small-scale images (MNIST, Frey Face), and natural images (CIFAR-10, CelebA) using both Gaussian Restricted Boltzmann Machines (GRBMs) and Deep EBLVMs.

  • Speed and Memory: In head-to-head comparisons on the Frey Face dataset, VaGES-DSM used only ~40% of the time and ~90% of the memory required by the strongest BiSM baseline while achieving comparable or superior performance.
  • Generative Performance: On CIFAR-10, VaGES-MDSM achieved an FID score of 28.93, outperforming standard EBMs and several other latent variable baselines. The models also demonstrated smooth latent space interpolations, indicating coherent learned representations.
  • KSD Scaling: When applied to Kernelized Stein Discrepancy, VaGES-KSD significantly outperformed importance-sampling-based baselines (IS-KSD) as the number of samples increased, demonstrating better scalability and stability.
Comparison of KSD training methods showing VaGES-KSD outperforming IS-KSD baselines.

Limitations and Future Work

While VaGES significantly advances the training of EBLVMs, challenges remain. Methods like KSD still struggle in extremely high-dimensional spaces due to the curse of dimensionality. Additionally, integrating latent variables into direct score-modeling networks (which model the score directly rather than the energy) remains an open problem. Finally, while the method avoids manual noise distribution design, further automating the selection of hyperparameters for the Langevin corrector could streamline the training process.

Summary updated

BibTeX
@inproceedings{bao2021variational,
  author = {Fan Bao and Kun Xu and Chongxuan Li and Lanqing Hong and Jun Zhu and Bo Zhang},
  title = {{Variational (Gradient) Estimate of the Score Function in Energy-based Latent Variable Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=GgNeuk3ADT},
}
Figure