Manuscript Offprint

arXiv:2611.26426

Exact Bayesian layers via characteristic functions

William H. W. Thompson, Guillaume St-Onge, Laurent Hébert-Dufresne, Jean-Gabriel Young

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Bayesian neural networks provide principled uncertainty estimates, but training them with Monte Carlo sampling can be expensive. Sampling-free variational inference algorithms make training Bayesian neural networks feasible, but existing approaches assume a Gaussian output distribution, which can be inaccurate in applied problems. Here, we introduce CF-Prop, an uncertainty propagation method that uses characteristic functions to compute the exact output distribution of a Bayesian ReLU layer, without any sampling, even for non-Gaussian predictive densities. Because CF-Prop propagates characteristic functions, the evidence lower bound—the objective of variational training—can be computed in closed form for a broad class of likelihoods, including the Gaussian, Poisson, and Gamma. This allows us to implement an efficient variational inference algorithm, CF-VI. On CIFAR-100, CF-VI achieves the lowest calibration error of any tested method, improving on the next best method by about 35%. On a heavy-tailed insurance claim dataset, CF-VI accurately captures tail uncertainty that is severely underestimated by both other sampling-free methods and Monte Carlo methods.

1 Introduction

Neural networks are the least reliable when training data is scarce. Bayesian Neural Networks (BNNs) offer a principled way to deal with the fundamental uncertainty of this data regime (Mitros and Mac Namee, 2019; Kristiadi et al., 2020). They quantify both epistemic uncertainty, which arises from limited knowledge of the model, and aleatoric uncertainty, which is due to the inherent randomness of the data-generating process. They excel in high-stakes, safety-critical applications (Ghoshal et al., 2021; Ding et al., 2021), perform well with limited data, prevent overfitting (Depeweg et al., 2018), and can increase fairness and reduce bias (Doherty et al., 2023).

BNNs quantify epistemic uncertainty by introducing a posterior distribution p(θ∣D)p(\bm{\theta}\mid\mathcal{D}) over the model parameters θ\bm{\theta}, given training data D\mathcal{D}. Propagating this uncertainty to the output η\eta is required for training and inference. Stochastic methods, such as Bayes by Backprop (Graves, 2011; Blundell et al., 2015), estimate it by sampling weights. Sampling-free methods, such as Deterministic Variational Inference (DVI) (Wu et al., 2019), CovProp (Wright et al., 2024), and Variational Bayesian Last Layers (VBLL) (Harrison et al., 2024), replace sampling with moment propagation, which removes noise at the cost of assuming a specific functional form for the pre-activations.

We argue that these methods break down exactly where uncertainty quantification matters most. Indeed, DVI, CovProp and VBLL assume that the predictive distribution and the variational family are Gaussians. However, many applied problems require accurate estimates of tail probabilities—the probability of a 100-year flood or a multi-million-dollar insurance claim—for distributions that are often far from Gaussian. This Gaussian assumption shows up in two places in these methods: the likelihood, which captures aleatoric uncertainty, and the distribution of the network, which captures epistemic uncertainty. But in practice, the likelihood can be skewed, in Gamma regressions for claim sizes, for example. And the distribution of the network output also tends to be skewed in these cases, because tail predictions are often dominated by a few rarely active neurons. Hence, non-Gaussian variational families are required to properly handle these cases. Any propagation method that models either distribution as Gaussian can severely underestimate tail risk. In practice, the BNN literature uses many other variational families: spike-and-slab families for sparsification (Hubin and Storvik, 2019), scale mixtures for shrinkage (Louizos et al., 2017; Ghosh et al., 2019), and multimodal mixtures (Dusenberry et al., 2020; Miller et al., 2017)—though current sampling-free propagation methods are incompatible with these families.

We introduce CF-Prop, an exact and sampling-free method for uncertainty propagation in a single-layer Bayesian perceptron that uses characteristic functions (CF). The forward pass of the layer is expressed in the Fourier domain, making the predictive density tractable. We use this propagation algorithm as the backbone of a new method, Variational Inference via Characteristic Functions (CF-VI). CF-VI extends sampling-free variational inference beyond the Gaussian regime by expressing the predictive density of the Bayesian layer exactly and in closed form. It allows for both non-Gaussian predictive distributions and non-Gaussian variational families. It can accommodate any likelihood and any variational family with a tractable characteristic function.

CF-VI can be used to train a fully exact Bayesian perceptron or as an exact Bayesian last layer on a sampling-free or stochastic trunk. We show that CF-VI performs well on traditional benchmarks such as UCI regressions, and provides state-of-the-art uncertainty quantification on classification tasks with a large number of labels such as CIFAR-100. We also show that CF-VI performs exceptionally well in uncertainty quantification for neural GLMs commonly used in the actuarial sciences. In particular, we show that for a Gamma regression task on heavy-tailed data—predicting the size of insurance claims—other methods severely underestimate uncertainty in the tails of the distribution. In contrast, our method provides an exact description of the tail uncertainty. CF-VI is also computationally efficient: In many common cases, it adds only a modest overhead to the training of a fully deterministic neural network.

Our contributions are as follows:

  1. An exact expression for the output distribution of a Bayesian ReLU layer using characteristic functions.
  2. CF-VI, a sampling-free variational inference method compatible with any mean-field variational family and a broad class of likelihoods.
  3. Lower training and inference cost than other sampling-free methods on UCI benchmarks, at comparable NLL.
  4. The best calibration among tested methods on CIFAR-100.
  5. Accurate tail uncertainty on heavy-tailed regression, where other tested methods underweight tail risk.

References (27)