Representing inferential uncertainty in deep neural networks through sampling

Patrick McClure, Nikolaus Kriegeskorte

Abstract

As deep neural networks (DNNs) are applied to increasingly challenging problems, they will need to be able to represent their own uncertainty. Modelling uncertainty is one of the key features of Bayesian methods. Bayesian DNNs that use dropout-based variational distributions and scale to complex tasks have recently been proposed. We evaluate Bayesian DNNs trained with Bernoulli or Gaussian multiplicative masking of either the units (dropout) or the weights (dropconnect). We compare these Bayesian DNNs' ability to represent their uncertainty about their outputs through sampling during inference. We tested the calibration of these Bayesian fully connected and convolutional DNNs on two visual inference tasks (MNIST and CIFAR-10). By adding different levels of Gaussian noise to the test images, we assessed how these DNNs represented their uncertainty about regions of input space not covered by the training set. These Bayesian DNNs represented their own uncertainty more accurately than traditional DNNs with a softmax output. We find that sampling of weights, whether Gaussian or Bernoulli, led to more accurate representation of uncertainty compared to sampling of units. However, sampling units using either Gaussian or Bernoulli dropout led to increased convolutional neural network (CNN) classification accuracy. Based on these findings we use both Bernoulli dropout and Gaussian dropconnect concurrently, which approximates the use of a spike-and-slab variational distribution. We find that networks with spike-and-slab sampling combine the advantages of the other methods: they classify with high accuracy and robustly represent the uncertainty of their classifications for all tested architectures.

Introduction

Standard deep learning models typically utilize a softmax output layer to provide a probability distribution over classes. While this captures aleatoric uncertainty—the noise inherent in the data—it often fails to account for epistemic uncertainty, which reflects the model's ignorance regarding its own parameters. In safety-critical applications, it is vital for a model to "know what it doesn't know." Bayesian Neural Networks (BNNs) address this by learning distributions over weights, but traditional Bayesian methods often struggle to scale to modern, high-dimensional architectures. This research explores practical, sampling-based approximations to Bayesian inference to robustly represent uncertainty.

Methodology

The researchers investigated several approximate Bayesian methods that employ multiplicative noise during both training and inference (Monte Carlo sampling). The primary variations studied include:

  • Bernoulli vs. Gaussian Noise: Bernoulli noise acts as a binary mask (on/off), whereas Gaussian noise scales signals by values drawn from a normal distribution.
  • Dropout vs. DropConnect: Dropout applies masking to units (neurons), while DropConnect masks individual weights (connections).
  • Spike-and-Slab Dropout: The authors propose a novel hybrid approach. A traditional spike-and-slab distribution consists of a "spike" at zero and a continuous "slab" (e.g., a Gaussian). By concurrently applying Bernoulli dropout to units and Gaussian dropconnect to weights, the model approximates this complex distribution without significantly increasing the parameter count.
Visual representation of different masking techniques, including the proposed Spike-and-Slab Dropout.

The "reparameterization trick" is utilized to ensure that these stochastic models remain differentiable and trainable via standard backpropagation.

Experimental Results

The methods were benchmarked on the MNIST and CIFAR-10 datasets. To evaluate robustness and uncertainty representation, varying levels of Gaussian noise were added to the test images, simulating out-of-distribution or corrupted data.

Weight vs. Unit Sampling

A key finding is that weight sampling (DropConnect) provides a more nuanced and robust representation of uncertainty compared to unit sampling (Dropout). This is likely because the higher dimensionality of the weight space allows for a more detailed capture of model doubt. Conversely, unit sampling tended to yield higher raw classification accuracy, particularly in convolutional architectures.

Performance of Spike-and-Slab Dropout

The proposed Spike-and-Slab Dropout successfully bridges the gap between accuracy and uncertainty representation. On the CIFAR-10 dataset, it maintained high classification accuracy while demonstrating superior calibration compared to standard Bernoulli Dropout.

Performance metrics on CIFAR-10 as a function of input noise. (a) Classification error, (b) Calibration MSE, and (c) Calibration MSE vs. Classification error.

Calibration and Robustness

Calibration—the alignment between a model's confidence and its actual accuracy—is a critical metric. The study found that Monte Carlo (MC) sampling at inference time significantly improved calibration, especially as input noise increased. Spike-and-Slab and DropConnect models showed graceful degradation in performance compared to standard Maximum A Posteriori (MAP) models.

Conclusion

This work demonstrates that sampling-based Bayesian approximations, particularly those involving weight noise, significantly enhance a DNN's ability to represent epistemic uncertainty. The Spike-and-Slab Dropout method emerges as a powerful tool, combining the predictive performance of dropout with the robust uncertainty estimation of weight-based sampling. Future research will focus on scaling these methods to larger datasets and exploring their utility in real-world applications such as autonomous systems.

Summary updated

Abstract

As deep neural networks (DNNs) are applied to increasingly challenging problems, they will need to be able to represent their own uncertainty. Modelling uncertainty is one of the key features of Bayesian methods. Bayesian DNNs that use dropout-based variational distributions and scale to complex tasks have recently been proposed. We evaluate Bayesian DNNs trained with Bernoulli or Gaussian multiplicative masking of either the units (dropout) or the weights (dropconnect). We compare these Bayesian DNNs ability to represent their uncertainty about their outputs through sampling during inference. We tested the calibration of these Bayesian fully connected and convolutional DNNs on two visual inference tasks (MNIST and CIFAR-10). By adding different levels of Gaussian noise to the test images, we assessed how these DNNs represented their uncertainty about regions of input space not covered by the training set. These Bayesian DNNs represented their own uncertainty more accurately than traditional DNNs with a softmax output. We find that sampling of weights, whether Gaussian or Bernoulli, led to more accurate representation of uncertainty compared to sampling of units. However, sampling units using either Gaussian or Bernoulli dropout led to increased convolutional neural network (CNN) classification accuracy. Based on these findings we use both Bernoulli dropout and Gaussian dropconnect concurrently, which approximates the use of a spike-and-slab variational distribution. We find that networks with spike-and-slab sampling combine the advantages of the other methods: they classify with high accuracy and robustly represent the uncertainty of their classifications for all tested architectures.
BibTeX
@misc{mcclure2017representing,
  author = {Patrick McClure and Nikolaus Kriegeskorte},
  title = {{Representing inferential uncertainty in deep neural networks through sampling}},
  year = {2017},
  eprint = {1611.01639},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1611.01639},
}
Figure