Meta-Learning Divergences for Variational Inference

Ruqi Zhang, Yingzhen Li, Christopher De Sa, Sam Devlin, Cheng Zhang

Abstract: Variational inference (VI) plays an essential role in approximate Bayesian inference due to its computational efficiency and broad applicability. Crucial to the performance of VI is the selection of the associated divergence measure, as VI approximates the intractable distribution by minimizing this divergence. In this paper we propose a meta-learning algorithm to learn the divergence metric suited for the task of interest, automating the design of VI methods. In addition, we learn the initialization of the variational parameters without additional cost when our method is deployed in the few-shot learning scenarios. We demonstrate our approach outperforms standard VI on Gaussian mixture distribution approximation, Bayesian neural network regression, image generation with variational autoencoders and recommender systems with a partial variational autoencoder.

Introduction

Variational Inference (VI) is a cornerstone of modern Bayesian machine learning, transforming the challenge of computing a posterior distribution into a more manageable optimization problem. By minimizing a divergence measure between a simple variational distribution and the true, often intractable, posterior, VI provides a scalable approach to approximate inference. However, the performance of VI is heavily dependent on the choice of divergence. While the Kullback-Leibler (KL) divergence is the standard choice due to its computational convenience, it often suffers from a "mode-seeking" bias, leading to underestimated uncertainty.

The Challenge of Divergence Selection

Selecting an appropriate divergence—such as from the $\alpha$-divergence or $f$-divergence families—is typically a manual process requiring significant domain expertise and trial-and-error. There is no universal "one size fits all" divergence; the optimal choice varies significantly across different tasks and datasets. For instance, a divergence that excels in image generation might perform poorly in recommender systems.

Approximation of a bimodal distribution using different $\alpha$-divergences, illustrating the trade-off between mode-seeking and mass-covering behaviors.

Methodology: Meta-Learning Divergences

We propose Meta-D, a meta-learning framework designed to automatically learn the optimal divergence metric for a given task. The framework operates through a nested optimization process:

  1. Inner Loop: Performs standard VI to optimize variational parameters (e.g., mean and variance) using the current learnable divergence.
  2. Outer Loop: Updates the divergence parameters by minimizing a "meta-loss," such as the negative log-likelihood (NLL) on a validation set.

We explore two primary parameterization strategies. Meta-$\alpha$ learns the scalar parameter of the Rényi $\alpha$-divergence family. Meta-$f$ employs a neural network to learn a flexible $f$-divergence. To ensure the resulting metric is mathematically valid (convex), the framework cleverly parameterizes the second derivative of the $f$ function. Additionally, the Meta-D&$\phi$ variant incorporates MAML-style initialization, allowing the model to learn both the optimal distance metric and a high-quality starting point for variational parameters, which is crucial for few-shot learning adaptation.

Experimental Evaluation

The Meta-D framework was evaluated across several domains, including Gaussian mixture models, Bayesian neural network (BNN) regression, and image generation using VAEs.

In the BNN regression task, the model was tasked with fitting a sine wave characterized by heteroskedastic (varying) noise. Standard VI using KL divergence often fails to capture these varying noise levels, leading to poor uncertainty calibration. In contrast, our meta-learned divergences successfully adapted to the noise profile, providing superior uncertainty estimates.

Sinusoid regression results using meta-learned $\alpha$, showing effective capture of heteroskedastic noise and uncertainty.

Key Results

  • Gaussian Mixtures: In toy experiments, the meta-learning algorithm successfully "discovered" known optimal divergences, converging to $\alpha \approx 0.52$ when the target evaluation metric was $\alpha = 0.5$.
  • BNN Regression: Meta-learned divergences achieved a significantly higher Test Log-Likelihood (-0.39) compared to standard VI (-0.59).
  • Few-Shot Learning: On the MNIST dataset, Meta-D outperformed standard VAEs across all test digits, demonstrating faster convergence and better marginal log-likelihoods.

Conclusion

Meta-learning divergences offers a powerful path toward automating the design of variational inference methods. By treating the divergence as a learnable component, we can discover task-specific metrics that outperform traditional hand-tuned choices, particularly in complex scenarios requiring precise uncertainty estimation. While the computational cost of the outer-loop optimization is a consideration, the gains in accuracy and adaptation speed make it a compelling approach for modern Bayesian deep learning.

Summary updated

BibTeX
@inproceedings{zhang2021meta,
  author = {Ruqi Zhang and Yingzhen Li and Christopher De Sa and Sam Devlin and Cheng Zhang},
  title = {{Meta-Learning Divergences for Variational Inference}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2021},
  url = {https://openreview.net/forum?id=c1yjFDDwsZD},
}
Figure