Bi-level Score Matching for Learning Energy-based Latent Variable Models

Fan Bao, Chongxuan Li, Taufik Xu, Hang Su, Jun Zhu, Bo Zhang

Introduction

Energy-based models (EBMs) offer a flexible framework for defining probability distributions via unnormalized energy functions. However, their training is traditionally hampered by the intractability of the partition function. While Score Matching (SM) provides a workaround for fully visible models, extending it to Latent Variable Models (EBLVMs) has historically required restrictive structural assumptions. This paper introduces Bi-level Score Matching (BiSM), a framework that enables the training of general, non-structural EBLVMs—such as those parameterized by deep convolutional neural networks—without needing to calculate the partition function.

Methodology: A Bi-level Optimization Approach

The core innovation of BiSM lies in reformulating score matching as a bi-level optimization problem to handle intractable marginal score functions. In standard score matching, one minimizes the Fisher divergence between the model's score function and the data's score function. For EBLVMs, the marginal score function involves an integral over latent variables, which is generally intractable. BiSM addresses this by introducing a variational posterior $q(h|v; \phi)$.

  1. Bi-level Formulation: The process is split into two levels. The lower level learns a variational posterior to approximate the model's true posterior of latent variables by minimizing a divergence measure (e.g., KL or Fisher divergence). The higher level then optimizes the model parameters $\theta$ using a modified score matching objective that leverages this variational posterior.
  2. Gradient Unrolling: To ensure the model parameters $\theta$ are updated correctly, the authors account for the dependency of the optimal variational parameters on $\theta$. Since the optimal variational parameters have no closed-form solution, the authors "unroll" $N$ steps of the lower-level gradient descent, treating the optimization path as a differentiable sequence. This allows for the computation of accurate gradients for the higher-level objective via backpropagation through the optimization process.

Theoretical analysis confirms that under nonparametric assumptions, BiSM is equivalent to the original score matching objective, providing a sound foundation for the stochastic optimization algorithm.

Experimental Evaluation

The effectiveness of BiSM was validated across several benchmarks, ranging from synthetic toy data to high-resolution natural images.

Density Estimation on Toy Data

On a 2D checkerboard dataset, BiSM variants (such as BiSSM and BiDSM) demonstrated a superior ability to capture complex, multimodal densities compared to standard score matching and contrastive divergence baselines. The bi-level approach allows the model to better approximate the underlying data distribution by effectively utilizing the latent space.

Density estimation on toy 2D checkerboard data across various score matching and contrastive divergence methods.

Image Generation and Feature Extraction

The model was further tested on MNIST, CIFAR10, and CelebA. A significant finding is that the inclusion of latent variables markedly improves generative quality. On CIFAR10, the BiMDSM variant achieved a Fréchet Inception Distance (FID) of 34.55, a substantial improvement over the fully visible baseline (MDSM) which scored 39.12.

Comparison of generated samples from fully visible MDSM and latent-variable BiMDSM on MNIST and CIFAR10 datasets.

Beyond generation, the latent variables learned by BiSM capture meaningful semantic features. A linear SVM trained on these features achieved 97.75% accuracy on MNIST and 46.46% on CIFAR10, significantly outperforming SVMs trained on raw pixels.

Key Insights

  • Architectural Flexibility: By treating the energy function as a "black box," BiSM removes the need for specific architectures (like RBMs), allowing the use of modern deep ResNets.
  • Inference via Fisher Divergence: The authors highlight Fisher divergence as a potent alternative to KL divergence for variational inference in continuous latent spaces, particularly when gradients are the primary focus.
  • The Role of Latents: Latent variables are shown to be crucial for capturing the complexity of multimodal natural data distributions, leading to sharper and more recognizable image samples.

Conclusion and Future Work

BiSM represents a significant step forward in training deep EBLVMs, though it introduces computational overhead—training on CIFAR10 takes approximately 50% longer than fully visible models. Future research may focus on simplifying gradient approximations to reduce this overhead and exploring applications in semi-supervised learning or discrete latent spaces.

Summary updated

BibTeX
@inproceedings{bao2020bi,
  author = {Fan Bao and Chongxuan Li and Taufik Xu and Hang Su and Jun Zhu and Bo Zhang},
  title = {{Bi-level Score Matching for Learning Energy-based Latent Variable Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure