Adaptive Bayesian Sampling with Monte Carlo EM

Anirban Roychowdhury, Srinivasan Parthasarathy

Abstract

Hamiltonian Monte Carlo (HMC) is a cornerstone of Bayesian inference, yet its performance is highly sensitive to the choice of the mass matrix. While Riemannian samplers offer a way to adapt this matrix to the local geometry of the target distribution, they introduce significant computational overhead, often requiring $O(D^3)$ matrix inversions. This paper introduces a novel framework that uses Monte Carlo Expectation-Maximization (MCEM) to adaptively tune the mass matrix. By treating the mass matrix as a parameter to be learned in an outer loop, the proposed method achieves the accuracy of Riemannian samplers while running up to an order of magnitude faster.

Introduction

In Bayesian machine learning, sampling from complex, high-dimensional posterior distributions is a fundamental challenge. Hamiltonian Monte Carlo (HMC) addresses this by simulating physical dynamics to explore the parameter space efficiently. However, the efficiency of HMC is governed by the "mass matrix," a hyperparameter that scales the momentum of the particles. A poorly tuned mass matrix leads to slow mixing and inefficient exploration.

To address this, Riemannian HMC (RHMC) was developed to adapt the mass matrix based on the local curvature of the log-posterior. While theoretically elegant, RHMC is computationally expensive because it requires solving implicit equations and performing matrix inversions at every integration step. This makes it impractical for high-dimensional problems. This research proposes a middle ground: an adaptive framework that learns the optimal mass matrix without the heavy computational burden of Riemannian dynamics.

Methodology: The MCEM Framework

The core innovation of this work is the decoupling of the manifold geometry from the sampler's dynamics. Instead of embedding the geometry directly into the differential equations, the authors treat the mass matrix as a parameter to be optimized via a Monte Carlo Expectation-Maximization (MCEM) framework.

The E-Step and M-Step

The algorithm operates in two alternating phases:

  1. The E-Step (Expectation): The sampler runs standard dynamics (such as HMC or Stochastic Gradient HMC) to collect samples of the model parameters and their associated auxiliary momentum variables.
  2. The M-Step (Maximization): The collected momentum samples are used to update the mass matrix. Since momentum in HMC is typically sampled from a Gaussian distribution defined by the mass matrix, these samples provide a direct proxy for the underlying geometry. The mass matrix is updated via maximum likelihood estimation.

Computational Efficiency

To maintain high performance, the authors utilize an online running average to update the inverse mass matrix directly. This approach circumvents the need for $O(D^3)$ matrix inversions during the sampling process. Furthermore, the framework incorporates Dynamic Sample Sizing, which adaptively increases the number of samples gathered in the E-step as the algorithm approaches convergence, preventing computational waste during the early stages of training.

Stochastic Dynamics

For large-scale datasets where full-batch gradients are unavailable, the paper introduces SG-NPHMC, a stochastic sampler based on Nosé-Poincaré dynamics. This variant is designed to be robust against the noise introduced by minibatches while still benefiting from the EM-based mass matrix adaptation.

Experimental Evaluation

The researchers evaluated the EM-augmented samplers against standard HMC and Riemannian baselines across several benchmarks:

  • Bayesian Logistic Regression: Using the Australian Credit and Heart disease datasets, the HMC-EM variant demonstrated significant speedups. It was approximately 13 times faster per iteration than Riemannian HMC (RHMC) while maintaining comparable error rates.
  • High-Dimensional Topic Modeling: On the 20-Newsgroups and Reuters Corpus Volume 1 datasets, the authors employed a Nonparametric Gamma Process model. The SGNHT-EM sampler achieved a test perplexity of 719 on 20-Newsgroups, outperforming both the standard SGNHT (757) and the more complex SGR-NPHMC (723).

Key Insights

The primary contribution of this work is the demonstration that geometric adaptation does not require the mathematical overhead of Riemannian manifolds. By leveraging the relationship between momentum samples and the mass matrix, the MCEM framework allows the sampler to "learn" the landscape of the distribution. This approach scales effectively to high-dimensional problems where traditional Riemannian methods fail.

Limitations and Future Work

While the framework is highly effective for second-order dynamics (samplers using momentum), its application to first-order adaptive samplers like SGLD remains unexplored. Additionally, while the framework supports full mass matrices, the current experiments largely utilize diagonal approximations for very high-dimensional tasks. Future research could investigate structured or sparse non-diagonal matrices to capture more complex correlations without sacrificing the $O(D)$ or $O(D^2)$ efficiency gains.

Summary updated

BibTeX
@inproceedings{roychowdhury2017adaptive,
  author = {Anirban Roychowdhury and Srinivasan Parthasarathy},
  title = {{Adaptive Bayesian Sampling with Monte Carlo EM}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2017},
}
Figure