Semi-Implicit Variational Inference via Score Matching

Longlin Yu, Cheng Zhang

Abstract

Semi-implicit variational inference (SIVI) greatly enriches the expressiveness of variational families by considering implicit variational distributions defined in a hierarchical manner. However, due to the intractable densities of variational distributions, current SIVI approaches often use surrogate evidence lower bounds (ELBOs) or employ expensive inner-loop MCMC runs for unbiased ELBOs for training. In this paper, we propose SIVI-SM, a new method for SIVI based on an alternative training objective via score matching. Leveraging the hierarchical structure of semi-implicit variational families, the score matching objective allows a minimax formulation where the intractable variational densities can be naturally handled with denoising score matching. We show that SIVI-SM closely matches the accuracy of MCMC and outperforms ELBO-based SIVI methods in a variety of Bayesian inference tasks.

Introduction

In Bayesian inference, approximating complex posterior distributions is a fundamental challenge. Traditional Variational Inference (VI) typically relies on simple, tractable distributions like Gaussians. While efficient, these simple families often fail to capture the multi-modality or complex geometries of real-world posteriors. Semi-Implicit Variational Inference (SIVI) addresses this by introducing a hierarchical structure: a latent code $z$ is sampled from a mixing distribution $q_\phi(z)$, which then parameterizes a conditional distribution $q_\phi(x|z)$. This creates a highly flexible marginal distribution $q_\phi(x) = \int q_\phi(x|z)q_\phi(z)dz$.

The primary hurdle in SIVI is that the marginal density $q_\phi(x)$ is generally intractable. Existing training methods either use biased surrogate objectives or computationally expensive inner-loop MCMC simulations. SIVI-SM provides a more efficient and accurate alternative by leveraging score matching.

Methodology: Score Matching and Minimax Optimization

Instead of maximizing the Evidence Lower Bound (ELBO), which requires evaluating the intractable log-density $\log q_\phi(x)$, SIVI-SM minimizes the Fisher divergence between the variational distribution and the target posterior. This objective depends only on the "scores"—the gradients of the log-densities with respect to the data $x$.

To handle the intractable variational score $\nabla_x \log q_\phi(x)$, the authors propose a minimax formulation. They introduce an auxiliary "critic" network $f_\psi(x)$ that estimates the difference between the target score and the variational score. By utilizing a denoising score matching trick that exploits the simple form of the conditional $q_\phi(x|z)$, the training process avoids the need for explicit marginal density evaluation.

Training dynamics of SIVI-SM on an X-shaped toy distribution, showing particles converging to the target geometry over time.

The resulting algorithm alternates between updating the critic to better identify discrepancies and updating the variational parameters to minimize those discrepancies, similar to the training of Generative Adversarial Networks (GANs).

Experimental Evaluation

The researchers evaluated SIVI-SM on several benchmarks, ranging from synthetic toy problems to high-dimensional Bayesian neural networks.

Synthetic and Low-Dimensional Tasks

On complex toy distributions like the "X-shape," SIVI-SM demonstrated an ability to capture non-linear, multi-modal structures that standard VI methods struggle with. In the Waveform dataset (22 dimensions), SIVI-SM's posterior estimates were found to be significantly more accurate than those of surrogate ELBO methods, which often underestimate posterior variance.

High-Dimensional Inference

SIVI-SM was tested on high-dimensional tasks including Multinomial Regression on MNIST (7,850 dimensions) and Human Activity Recognition (HAPT, 6,744 dimensions). Unlike previous score-matching or MCMC-based SIVI methods, SIVI-SM scales effectively to these dimensions because it relies on standard backpropagation rather than expensive Jacobian computations or long sampling chains.

Comparison of posterior approximations for SIVI-SM, SIVI, and UIVI. SIVI-SM (left) shows superior alignment with the ground truth contours compared to its predecessors.

Bayesian Neural Networks

In UCI regression benchmarks, SIVI-SM consistently outperformed SIVI, UIVI, and SGLD in terms of Root Mean Squared Error (RMSE) and Negative Log-Likelihood (NLL). For instance, on the Yacht Hydrodynamics dataset, SIVI-SM reduced the RMSE to 1.559, compared to 1.902 for standard SIVI.

Conclusion and Future Work

SIVI-SM represents a significant step forward for hierarchical variational inference. By reframing the problem through the lens of score matching and minimax optimization, it achieves high accuracy without the computational burden of MCMC. While the adversarial training requires careful hyperparameter tuning, the method's success in high-dimensional BNNs suggests it is a robust tool for modern Bayesian deep learning. Future research may explore more complex mixing distributions and applications in large-scale generative modeling.

Summary updated

BibTeX
@misc{yu2023semi,
  author = {Longlin Yu and Cheng Zhang},
  title = {{Semi-Implicit Variational Inference via Score Matching}},
  year = {2023},
  eprint = {2308.10014},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.10014},
}
Figure