Variational Inference for Bayesian Neural Networks under Model and Parameter Uncertainty

Aliaksandr Hubin, Geir StorvikarXiv 2023 · DOI

Abstract

Deep learning models are characterized by significant over-parameterization, leading to challenges in computational efficiency and uncertainty quantification. While Bayesian Neural Networks (BNNs) provide a robust framework for parameter uncertainty, they often overlook structural or model uncertainty. This paper introduces Latent Binary Bayesian Neural Networks (LBBNNs), a framework that utilizes variational inference and continuous relaxations to simultaneously learn network weights and optimal sparse structures. Our approach demonstrates that joint inference over parameters and models results in highly efficient architectures that maintain high accuracy while providing superior out-of-distribution robustness.

1. Introduction

Standard deep learning models typically rely on frequentist approaches where pruning—the removal of redundant connections—is performed as an ad-hoc post-processing step. While effective for reducing memory footprints, these methods do not account for model uncertainty: the probabilistic question of whether a specific connection should exist. Bayesian Neural Networks (BNNs) offer a principled alternative by treating weights as probability distributions. However, standard BNNs primarily address parameter uncertainty (the values of the weights) rather than structural uncertainty (the architecture itself).

Incorporating structural uncertainty traditionally involves "spike-and-slab" priors, which combine a discrete mass at zero (the spike) with a continuous distribution (the slab). Historically, these priors have been difficult to scale to deep architectures due to the exponential complexity of searching the model space. This paper presents a scalable, gradient-based approach for joint inference over both parameters and structures using Latent Binary Bayesian Neural Networks (LBBNNs).

2. Methodology

2.1 The LBBNN Framework

The core of the LBBNN is the multiplication of every weight $\beta$ by a latent binary variable $\gamma \in \{0, 1\}$. The resulting effective weight is zero if $\gamma=0$ (the "spike") and follows a Gaussian distribution if $\gamma=1$ (the "slab"). This formulation allows the model to explicitly represent the presence or absence of every connection in the network.

2.2 Variational Inference and Concrete Relaxation

To avoid the prohibitive costs of Markov Chain Monte Carlo (MCMC) sampling, we employ Variational Inference (VI) to approximate the joint posterior of weights and structures by optimizing the Evidence Lower Bound (ELBO). Because binary variables are non-differentiable, we utilize the "Concrete" distribution—a continuous relaxation of the Bernoulli distribution. This enables the use of the reparameterization trick, allowing the inclusion probabilities of weights to be trained via standard backpropagation.

2.3 Dependence Structures

While many BNNs rely on "Mean-Field" assumptions (assuming independence between all weights), we explore more complex dependence structures. By testing Multivariate Normal (MVN) and Low-Factor MVN structures, we capture correlations between neurons, allowing the model to learn which groups of connections are likely to be active together.

3. Experimental Setup

We evaluated the LBBNN framework across three distinct classification benchmarks:

  1. MNIST: A standard dataset of handwritten digits.
  2. Fashion-MNIST (FMNIST): A more complex dataset of clothing items used to test model capacity.
  3. PHONEME: A speech recognition dataset focused on the classification of nasal versus oral vowels.

4. Results and Discussion

4.1 Automatic Sparsification and Structural Emergence

Unlike dropout, which is a training heuristic, LBBNNs treat sparsity as an intrinsic part of the probabilistic model. The network learns to prune redundant connections automatically. An intriguing finding was the emergence of CNN-like structures: when starting with a fully connected architecture, the model naturally learned sparse connections in early layers and denser connections in later layers, mimicking the hierarchical feature extraction of Convolutional Neural Networks.

4.2 Accuracy vs. Efficiency

On the MNIST dataset, the LBBNN achieved approximately 98% accuracy while utilizing only 8–9% of the total weights. We found that the Median Probability Model (MPM)—a sub-model created by retaining only weights with an inclusion probability greater than 0.5—yielded extremely sparse yet highly accurate models. These models perform on par with full model averaging but at a fraction of the computational cost during inference.

4.3 Out-of-Distribution (OOD) Robustness

LBBNNs provide more reliable uncertainty estimates than frequentist models. When trained on MNIST and tested on FMNIST (and vice versa), the model's entropy (uncertainty) increased significantly. This indicates that the model "knows what it doesn't know," whereas standard models often produce overconfident, incorrect predictions on OOD data.

4.4 Computational Performance

While Bayesian inference introduces additional latent variables, the LBBNN-GP-MF approach was only approximately 1.6x slower per epoch than a standard dense BNN. This represents a manageable trade-off given the significant gains in sparsity and the improved quality of uncertainty quantification.

5. Conclusion and Future Work

This work demonstrates that joint variational inference over model structure and parameters is both scalable and effective. LBBNNs offer a path toward models that are not only smaller but also more robust and honest about their predictions. Future research will focus on extending this framework to optimize network depth (layer selection) and applying these techniques to more complex architectures such as Transformers and large-scale vision models.

Summary updated

BibTeX
@misc{hubin2023variational,
  author = {Aliaksandr Hubin and Geir Storvik},
  title = {{Variational Inference for Bayesian Neural Networks under Model and Parameter Uncertainty}},
  year = {2023},
  eprint = {2305.00934},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.00934},
}
Figure