Importance Sampled Stochastic Optimization for Variational Inference

Joseph Sakaya, Arto Klami · DOI

Abstract

Variational inference approximates the posterior distribution of a probabilistic model with a parameterized density by maximizing a lower bound for the model evidence. Modern solutions fit a flexible approximation with stochastic gradient descent, using Monte Carlo approximation for the gradients. This enables variational inference for arbitrary differentiable probabilistic models, and consequently makes variational inference feasible for probabilistic programming languages. In this work we develop more efficient inference algorithms for the task by considering importance sampling estimates for the gradients. We show how the gradient with respect to the approximation parameters can often be evaluated efficiently without needing to re-compute gradients of the model itself, and then proceed to derive practical algorithms that use importance sampled estimates to speed up computation. We present importance sampled stochastic gradient descent that outperforms standard stochastic gradient descent by a clear margin for a range of models, and provide a justifiable variant of stochastic average gradients for variational inference.

Introduction

Variational Inference (VI) has become a cornerstone of Bayesian machine learning, particularly through "black-box" techniques that utilize Stochastic Gradient Descent (SGD) to maximize the Evidence Lower Bound (ELBO). However, these methods are computationally intensive. Every optimization step requires expensive Monte Carlo estimates of the model's gradients. In many real-world applications, calculating the gradient of the model's log-likelihood with respect to latent variables is the primary bottleneck.

Sakaya and Klami propose a method to stop wasting these expensive computations. By applying Importance Sampling (IS) to the optimization process, they demonstrate how previous gradient evaluations can be reused to take multiple optimization steps for the price of one, leading to significant speedups in convergence.

Methodology: Reusing Gradients via Importance Sampling

The core innovation is an Importance Sampling estimate for gradients. In the reparameterization trick, the gradient of the ELBO is expressed as a product of the model gradient (with respect to latent variables) and the gradient of the transformation function (with respect to variational parameters).

The authors observe that the model gradient depends on the samples but not directly on the variational parameters. When parameters move from $\lambda$ to $\lambda'$, the existing model gradients can be "re-weighted" using importance weights rather than being re-calculated from scratch. This allows for "cheap" optimization steps that avoid the heavy lifting of model re-evaluation.

Algorithm for calculating importance sampled gradients.

Key Algorithms

  • I-SGD (Importance Sampled SGD): Instead of one step per mini-batch, I-SGD takes several. The first step uses a standard gradient, while subsequent steps use the IS estimate. This follows the non-linear geometry of the objective function more accurately than simple momentum.
  • I-SAG (Importance Sampled SAG): Standard Stochastic Average Gradient (SAG) fails in VI because gradients become "stale" as the distribution moves. I-SAG uses importance sampling to "freshen" these gradients, making them relevant to the current parameters.

The Dimensionality Challenge and Factorization

Importance sampling famously suffers from the "curse of dimensionality," where weights collapse to zero as the number of dimensions increases. The authors address this by leveraging mean-field approximations. By factorizing the variational distribution into independent low-dimensional components, IS can be applied to each factor (typically up to ~10 dimensions) individually.

Mean importance weights over optimization steps for varying dimensionalities.

As illustrated above, the importance weights remain viable for many steps in low-dimensional settings but decay rapidly as dimensionality increases. This factorization is the "secret sauce" that makes the method practical for high-dimensional models.

Experimental Results

The authors evaluated their methods on models including Bayesian Linear Regression, Gaussian Mixture Models, and Poisson Likelihood models.

  • 10x Speedup: In experiments using the reparameterization trick, I-SGD reached the optimum roughly 10 times faster than standard SGD in terms of wall-clock time.
  • Stability: I-SAG proved significantly more stable and accurate than naive SAG implementations, which often diverge in VI settings due to stale gradient information.
  • Score Function Efficiency: Even for the score function estimator, where gains are typically smaller, I-SGD outperformed standard SGD when log-probability evaluation was the dominant cost.

Conclusion and Future Work

By introducing importance sampling into stochastic optimization, this work provides a mathematically justified way to reuse expensive gradient information. While the method relies on the invertibility of transformation functions and is constrained by the dimensionality of variational factors, it offers a clear path toward more efficient Bayesian inference. Future research may explore more sophisticated resampling heuristics and extensions to complex structured approximations.

Summary updated

BibTeX
@inproceedings{sakaya2017importance,
  author = {Joseph Sakaya and Arto Klami},
  title = {{Importance Sampled Stochastic Optimization for Variational Inference}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2017},
}
Figure