Approximate Message Passing for Bayesian Neural Networks

Romeo Sommerfeld, Christian Helms, Jan Niklas Groeneveld, Rainer Schlosser, Ralf Herbrich · Submission to ICLR 2026 · Rejected

TL;DR

This paper introduces an approximate message passing (MP) framework for Bayesian Neural Networks (BNNs) that scales to convolutional networks without double-counting data. By representing the network's predictive posterior as a factor graph and updating beliefs through moment matching rather than gradient-based variational optimization, the method achieves state-of-the-art calibration and competitive accuracy on CIFAR-10 without requiring hyperparameter tuning.

What Problem Does This Paper Address?

Deep neural networks are notorious for being confidently wrong when evaluated on ambiguous or out-of-distribution (OOD) data. While Bayesian Neural Networks (BNNs) provide a principled framework for epistemic uncertainty quantification by placing distributions over weights, existing inference methods suffer from practical roadblocks:

  • Markov Chain Monte Carlo (MCMC): Asymptotically exact, but computationally prohibitive for high-dimensional neural networks.
  • Variational Inference (VI): Scalable, but prone to overconfidence, posterior collapse (especially under mean-field assumptions), and cumbersome hyperparameter tuning.
  • Prior Message Passing (MP): Earlier attempts (like Probabilistic Backpropagation or belief propagation on MLPs) repeatedly treated seen training data as independent new observations across epochs. This double-counting caused the posterior variance to collapse toward zero, generating extreme overconfidence.

The authors set out to build a scalable, pure message-passing framework capable of training deep continuous-weight models—including convolutional architectures—while strictly avoiding data double-counting.

Methods

The predictive posterior $p(y \mid x, \mathcal{D})$ is cast into an explicit bipartite factor graph down to the scalar level using elementary Dirac delta factors connecting latent variables.

       [ Prior p(W) ]
             │
             ▼
Input x ──► [Layer Factors] ──► Activations ──► Output y
                 ▲
                 │ (Forward / Backward Gaussian Messages)

Key technical elements include:

  • Gaussian Parameterization: Messages are approximated as 1D Gaussians in natural parameters $(\tau = \mu / \sigma^2, \rho = 1 / \sigma^2)$. In this form, message products simplify to component-wise additions, and division corresponds to subtraction.
  • Moment Matching for Non-linearities: Dirac delta factors for linear operations yield closed-form Gaussian messages. Non-linearities (such as LeakyReLU) yield non-Gaussian or improper distributions; the authors derive both direct and marginal moment-matching equations to approximate them as Gaussians.
  • Batching Without Double-Counting: To make training tractable on larger datasets, only an active batch of $b$ examples is instantiated in the graph. The messages from the remaining inactive data points are aggregated into a single summary message. When switching batches, the marginal is divided by the batch's prior incoming message and multiplied by the newly updated one, ensuring each data point contributes exactly once to the posterior.
  • Vectorized Layer Abstraction: Rather than building graph nodes for every scalar variable, custom GPU kernels (in Julia using CUDA.jl and Tullio.jl) execute whole-layer forward and backward passes across batches, achieving a ~300× speedup over naive graph construction.

Datasets

  • Synthetic 1D Regression: 200 points generated from $f(x) = 0.5x + 0.2\sin(2\pi x) + 0.3\sin(4\pi x)$ with additive Gaussian noise. Used to evaluate depth scaling and out-of-distribution uncertainty intervals.
  • CIFAR-10: Evaluated on a 6-layer convolutional network (~890k parameters) using standard training and test splits.
  • SVHN (Street View House Numbers): Used as an unseen out-of-distribution (OOD) test set against the CIFAR-10 trained model.

Key Insights and Ideas

  • Forward KL vs. Reverse KL: Standard VI minimizes $D_{\text{KL}}(q \parallel p)$ (reverse KL), which is "mode-seeking" and tends to underestimate variance, leading to overconfident predictions. In contrast, MP's moment matching minimizes $D_{\text{KL}}(p \parallel q)$ (forward KL) over local marginals, which is "mass-covering" and yields significantly better calibrated predictive uncertainties.
  • Solving Posterior Collapse via Message Division: Tracking batch-level messages and dividing them out before updating prevents the accumulation of phantom data evidence across training epochs.
  • Spectral Prior Initialization: Setting prior means via spectral parameterization helps the model learn features independent of network width while breaking internal mode symmetries.

Key Results

On a 6-layer CNN (~890k parameters) on CIFAR-10 trained for 25 epochs, MP matches or outperforms strong modern baselines like AdamW and IVON (a SOTA variational inference method) without requiring hyperparameter tuning:

Metric AdamW IVON (100 samples) MP (Ours)
Accuracy ↑ 0.783 0.772 0.773
Top-5 Accuracy ↑ 0.984 0.983 0.977
Negative Log-Likelihood (NLL) ↓ 1.736 1.316 0.997
Expected Calibration Error (ECE) ↓ 0.046 0.035 0.029
Brier Score ↓ 0.380 0.370 0.361
OOD-AUROC (SVHN) ↑ 0.792 0.808 0.810

On synthetic 1D data, credible intervals matched reality closely outside the training distribution, exhibiting a 0.90 correlation between posterior credible intervals and empirical coverage rates.

Limitations and Future Work

  • Compute and Memory Overhead: Training is up to two orders of magnitude slower than deterministic networks trained with PyTorch. It requires storing message representations per training example and defaults to FP64 precision in Julia.
  • Architecture Support: Modern components such as normalization layers (BatchNorm, LayerNorm) and residual connections are not yet supported in their engine, restricting experiments to plain feedforward and convolutional networks.
  • Prior Variance Drift: Forward message variances still grow exponentially with network depth, indicating that finding a fully principled prior initialization remains an open challenge.
  • Future Work: The authors propose reimplementing core routines in optimized CUDA C++, designing batched forward schedules, and formulating scalar message equations for division, exponentiation, and softargmax to support ResNets and Transformers.

Summary updated

BibTeX
@misc{sommerfeld2025approximate,
  author = {Romeo Sommerfeld and Christian Helms and Jan Niklas Groeneveld and Rainer Schlosser and Ralf Herbrich},
  title = {{Approximate Message Passing for Bayesian Neural Networks}},
  year = {2025},
  eprint = {2501.15573},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.15573},
}
Figure