One-Shot Inference in Markov Random Fields

Hao Xiong, Yuanzhen Guo, Yibo Yang, Nicholas RuozziUAI 2019

Abstract

Statistical inference in Markov random fields (MRFs) is NP-hard in all but the simplest of cases. As a result, many algorithms, particularly in the case of discrete random variables, have been developed to perform approximate inference in practice. However, most of these methods scale poorly, cannot be applied to continuous random variables, or are too slow to be used in situations that call for repeated statistical inference on the same model. In this work, we propose a novel variational inference strategy that is flexible enough to handle both continuous and discrete random variables, efficient enough to be able to handle repeated statistical inferences, and scalable enough, via modern GPUs, to be practical on MRFs with hundreds of thousands of random variables. We prove that our approach overcomes weaknesses of the current approaches and demonstrate the efficacy of our approach on both synthetic models and real-world applications.

Introduction

Markov Random Fields (MRFs) are powerful tools for modeling local relationships between random variables, yet they suffer from a significant "usability gap" compared to modern deep neural networks. Inference tasks—answering queries like "what is the most likely state?"—are generally NP-hard. While algorithms like Belief Propagation (BP) exist, they often scale poorly, can diverge, or become unbounded when dealing with continuous variables.

Furthermore, traditional MRF inference is "lazy": every time evidence changes or a new query is posed, expensive optimizations must be re-run from scratch. This lack of amortization makes MRFs impractical for real-time applications or large-scale computer vision tasks where deep learning currently dominates.

Methodology: One-Shot Inference (OSI)

The proposed One-Shot Inference (OSI) is a variational strategy that approximates the MRF's distribution using a mixture of fully factorized distributions.

Mixture Representation and BFE Optimization

Instead of complex message-passing, OSI represents node and edge "beliefs" as a weighted sum of $K$ simple, independent distributions (such as Gaussians or Betas). The parameters of these mixtures are optimized by minimizing the Bethe Free Energy (BFE) using standard gradient descent. Because the mixture components are factorized, the local consistency constraints required by the BFE are satisfied automatically. A major theoretical contribution is the proof that the BFE is bounded from below for Gaussian mixtures, ensuring convergence where standard BP might fail.

The "One-Shot" Advantage and GPU Scaling

Once the mixture parameters are learned, various inference tasks—including Marginalization, MAP, and Marginal MAP—can be computed in linear time directly from the mixture. This amortizes the cost of inference, allowing one round of training to support many different queries nearly instantly. To handle massive MRFs, the authors leverage GPU acceleration; the gradient of the BFE involves expectations over local cliques, which are "embarrassingly parallel" and well-suited for vectorized tensor operations.

Experimental Evaluation

The efficacy of OSI was evaluated across a diverse range of benchmarks, including synthetic tree-structured models, UCI repository datasets, image completion (MNIST and Kassel OCR), and complex computer vision tasks like Stereo Depth Estimation.

Performance on synthetic tree-structured MRFs. (a) The tree structure used for evaluation. (b) Percentage of correct solutions vs. coupling strength. (c) Relative error vs. coupling strength. OSI (mixture-K) consistently maintains higher accuracy and lower error than mixed product BP as coupling increases.

Key Results

  • Speed and Efficiency: In MNIST image completion tasks, OSI was 20x faster than D-PMP (a state-of-the-art particle-based method) while achieving better energy values and lower mean squared error. For Stereo Depth Estimation, OSI converged in 30 seconds, compared to 246 seconds for Tree-Reweighted BP.
  • Robustness: On UAI challenge discrete grids, OSI significantly outperformed Mixed-Product BP. This is likely because mixture-based beliefs are always "realizable" (corresponding to a valid joint distribution), whereas BP's local beliefs often are not.
  • Amortized Performance: On synthetic trees, OSI performed 56 different Marginal MAP queries in just 40 seconds, while the baseline required 250 seconds because it had to be re-run for every single query.

Discussion and Future Work

OSI demonstrates that MRFs can compete with modern neural architectures in terms of scale and speed. However, the accuracy of the approximation depends on the number of mixture components ($K$); while higher $K$ improves accuracy, it increases the initial training time. Additionally, as the BFE is generally non-convex, the algorithm may occasionally settle in local optima. Future work will explore more complex mixture components to capture tighter correlations and more sophisticated integration techniques for high-dimensional continuous potentials.

Summary updated

BibTeX
@inproceedings{xiong2019one,
  author = {Hao Xiong and Yuanzhen Guo and Yibo Yang and Nicholas Ruozzi},
  title = {{One-Shot Inference in Markov Random Fields}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2019},
  url = {https://openreview.net/forum?id=zHx12knYW1},
}
Figure