Estimating Confidence for Deep Neural Networks through Density modeling

Akshayvarun Subramanya, Suraj Srinivas, R. Venkatesh Babu

TL;DR

Standard Deep Neural Networks (DNNs) are notoriously overconfident, often assigning high probability scores to noisy or even nonsensical images. This paper demonstrates that the ubiquitous "softmax" function has a fundamental mathematical flaw—it can be "tricked" into high confidence simply by increasing the magnitude of input features—and proposes a more robust alternative using density modeling (Gaussian distributions) in the feature space.

What Problem Does This Paper Address?

In modern computer vision, we typically use the softmax function at the final layer of a network to produce a probability distribution. While great for training, softmax is a poor measure of actual "predictive confidence."

The authors identify a specific "pathology": because DNNs use monotonically increasing activation functions (like ReLU), simply scaling up the magnitude of an input image often leads to higher softmax scores, even if the image hasn't become "clearer." This makes networks vulnerable to adversarial attacks and causes them to remain dangerously confident when faced with blurred, noisy, or compressed images that they should ideally flag as uncertain.

Methods

The authors move away from the traditional "distance-from-hyperplane" logic of softmax and instead adopt a Density Modelling approach.

  1. Feature Extraction: They look at the "pre-softmax" activations ($z$)—the raw numbers the network produces just before the final probability conversion.
  2. Class-Specific Densities: During training, they model the distribution of these features for each class using a multivariate Gaussian distribution with a diagonal covariance matrix.
  3. Bayesian Inference: At test time, instead of a simple softmax, they use Bayes' Rule to calculate the probability that a feature vector $z$ belongs to a specific class based on these learned Gaussian densities.
  4. The High-Dimension Fix: In high-dimensional spaces, standard Gaussians suffer from the "Annulus Theorem," where almost all probability mass sits in a thin shell far from the center, making density values vanish. To counter this, the authors scale the covariance by the dimensionality ($d$), ensuring the density values remain meaningful and discriminative.

Datasets

The researchers evaluated their approach on two standard benchmarks:

  • MNIST: The classic handwritten digit dataset, using a LeNet-5 architecture.
  • ImageNet (ILSVRC12): A large-scale image database, using the VGG-16 architecture to test the method's scalability to complex, real-world data.

Key Insights and Ideas

  • The Softmax Magnitude Trap: The paper provides a formal proof (Lemma 3.1) showing that for any input, increasing its $L_2$ norm (magnitude) will mathematically increase the softmax confidence. This proves that softmax confidence is tied to feature scale, not necessarily feature "correctness."
  • Density vs. Discriminative Boundaries: Traditional classifiers only care about which side of a line a point falls on. The authors argue that a "good" confidence measure should care about how close a point is to the actual cluster of known data. Points far away from all clusters (like random noise) should result in low confidence.
  • Robustness to Distortions: Unlike softmax, which often maintains high confidence even as an image is obliterated by Gaussian noise or blur, the density-based measure shows a "monotonically decreasing" profile—meaning as the image gets worse, the network's confidence actually drops, as it should.

Key Results

  • Noise and Blur: On MNIST, as Gaussian noise ($\sigma$) increased from 0 to 0.8, the proposed measure's confidence dropped significantly (from ~0.95 to ~0.57), while softmax remained deceptively high (~0.99).
  • Adversarial Robustness: The authors tested the models against adversarial examples (images specifically engineered to fool the AI). On the ImageNet validation set, softmax "failed" (showed increased confidence for the wrong label) 5,795 times. The proposed density measure reduced these failures to 2,214—a significant improvement in detecting that something was "off" about the adversarial input.
  • Qualitative Success: Visual examples show that for a "clean" image of a bird, both methods are confident. However, when that bird is heavily blurred or noisy, the density method's score plummets to near zero, while softmax often stays above 60-90%.

Limitations and Future Work

The authors acknowledge that while diagonal Gaussian models are computationally efficient, they are relatively simple. They hypothesize that some performance drops seen during heavy blurring or specific adversarial attacks are due to the difficulty of accurate density estimation in very high-dimensional spaces.

Future work suggests exploring more sophisticated density models (such as Gaussian Mixture Models or more complex distributions) that could better capture the intricate "shape" of data in the feature space, potentially leading to even more reliable uncertainty estimates.

Summary updated

Abstract

State-of-the-art Neural Networks can be easily fooled into providing incorrect high-confidence predictions for images with small amounts of adversarial noise. Does this expose a flaw with deep neural networks, or do we simply need a better way to estimate confidence? In this paper we consider the problem of accurately estimating predictive confidence. We formulate this problem as that of density modelling, and show how traditional methods such as softmax produce poor estimates. To address this issue, we propose a novel confidence measure based on density modelling approaches. We test these measures on images distorted by blur, JPEG compression, random noise and adversarial noise. Experiments show that our confidence measure consistently shows reduced confidence scores in the presence of such distortions - a property which softmax lacks.
BibTeX
@inproceedings{subramanya2018estimating,
  author = {Akshayvarun Subramanya and Suraj Srinivas and R. Venkatesh Babu},
  title = {{Estimating Confidence for Deep Neural Networks through Density modeling}},
  booktitle = {SPCOM},
  year = {2018},
  url = {https://openreview.net/forum?id=n0LXJFgFSv3},
}
Figure