Paper commentary
A Baseline for Detecting Misclassified and Out-of-Distribution Examples in Neural Networks
Softmax confidence flags misclassified and out-of-distribution inputs with a simple baseline
- Problem Classifiers return confident softmax predictions even when they are wrong or the input is from a different distribution. Single probabilities therefore hide errors that a reviewer needs to see.
- Method The authors use each example's maximum softmax probability as a detection score. Correct or in-distribution examples are separated from errors or abnormal inputs, and scored with AUROC and AUPR.
- Results For MNIST error detection the baseline reaches an AUROC of 97, against a random level of 50. The method works across vision, language and speech tasks.
Why confident softmax outputs mislead
Classifiers that receive inputs from a shifted distribution or that are simply mistaken often fail without signalling it, because they return confident predictions. In a medical setting, such silent errors could go unflagged for a human reviewer. The problem is tied to the softmax layer itself. Its probabilities come from an exponential, so small changes in the logits can move the output distribution a long way, and a softmax rarely returns a flat distribution for an input far from the training data.
A concrete case: random Gaussian noise fed to an MNIST classifier produced a predicted class probability of 91%. The authors conclude from this and related observations that the softmax prediction probability corresponds poorly to confidence when read on its own.
The score is not useless, however. Incorrect and out-of-distribution examples tend to receive lower prediction probabilities than correct in-distribution examples, so statistics computed over correct examples can flag errors and abnormal inputs even though a single probability can mislead. The work frames two related problems: error and success prediction, and in- versus out-of-distribution detection.
Scoring detectors without a fixed threshold
Accuracy is a misleading yardstick for a detector, since a detector that always predicts the negative class can score well when that class dominates. The authors therefore use AUROC, which does not depend on a threshold. It equals the probability that a positive example receives a higher detector score than a negative example, so a random detector sits at 50 and a perfect one at 100.
AUPR is reported as well, because AUROC is not ideal when the positive and negative classes have very different base rates. The random-detector level for AUPR equals the precision of the positive class, so the positive class has to be named explicitly for each result. For that reason the paper reports two AUPR values per setting: one with correct or in-distribution examples as the positive class, and one with errors or abnormal examples as the positive class, obtained by negating the scores.
Negating the scores does not change AUROC, since for a correct score S and an erroneous score E the identity P(S > E) = P(-E > -S) holds.
The maximum softmax probability baseline
For each test example, the method takes the largest class probability of the softmax output. Correctly and incorrectly classified test examples are then separated into two groups, and the scores of the two groups are evaluated as a binary detector. Success or In means treating correct or in-distribution examples as positive with the score unchanged.
Error or Out means treating the incorrect or out-of-distribution examples as positive with the negated score.
Each table also lists the random-detector level for AUPR, labelled Base, since the AUPR floor depends on how many positives there are. The mean predicted probability of wrong examples is reported next to these numbers to show how poorly that probability reads as confidence. The authors also tried the KL divergence of the softmax distribution from the uniform distribution.
Detection with it was highly correlated with detection by the maximum softmax probability.
Computer vision results
The vision experiments use MNIST, CIFAR-10 and CIFAR-100. The MNIST classifier is a three-layer fully connected network of width 256 trained for 30 epochs with Adam and a GELU nonlinearity, while the CIFAR models are 40-4 wide residual networks trained for 50 epochs with stochastic gradient descent and restarts. For error detection, the AUROC is 97 on MNIST, 93 on CIFAR-10 and 87 on CIFAR-100, against a random level of 50.
The mean predicted probability of wrong examples is 86 on MNIST, 80 on CIFAR-10 and 66 on CIFAR-100. Error detection is weaker where the classifier is less accurate: the test error is 1.69 on MNIST, 4.96 on CIFAR-10 and 20.7 on CIFAR-100, and the authors note that the area under the curves degrades as the test error rises.
For out-of-distribution detection, the in-distribution test set is the positive class. The out-of-distribution sets include SUN scenes for CIFAR, Omniglot, notMNIST and CIFAR-10bw for MNIST, plus synthetic Gaussian and uniform noise. Against all out-of-distribution CIFAR-10 sets together the AUROC is 96, and against all MNIST sets together it is 91.
The CIFAR-100 combined set gives 90. MNIST against notMNIST is the hardest MNIST pair, with an AUROC of 85, while MNIST against Omniglot reaches 96.
Language, text and speech results
On IMDB binary sentiment classification, a linear classifier over averaged randomly initialized word vectors of dimension 50 reaches an error-detection AUROC of 82, and against all out-of-distribution review sets combined the in-distribution AUROC is 94. The out-of-distribution sets are the Customer Review and Movie Review data, using 500 and 1000 test reviews respectively, with IMDB test reviews as in-distribution examples.
For text categorization the detection AUROCs are 89 on 20 Newsgroups, 89 on Reuters 8 and 91 on Reuters 52 for correct against incorrect classifications.
Out-of-distribution detection with the WSJ tagger gives an AUROC of 80 for tweets and 61 for weblog sentences. The authors mark the weblog examples as atypically close to the training distribution, and they note that detection is done per word.
The speech system is a two-layer bidirectional LSTM trained with connectionist temporal classification on TIMIT, so its softmax outputs are spiky and mostly blank. Computing the softmax probabilities without the blank symbol's logit is what lets the baseline separate normal from abnormal distributions. Under that change, TIMIT against all distorted and Chinese sets reaches an AUROC of 97, and TIMIT against the Chinese THCHS-30 set reaches 85.
The abnormality module and its training
The method starts from a normal classifier with an auxiliary decoder that reconstructs the input. The decoder and the classifier are trained jointly on in-distribution examples. Afterwards the layers trained in that first stage are frozen. A separate set of layers is then trained on clean and noised training examples, and its sigmoid output gives the abnormality score, with noised inputs as the abnormal class.
In the TIMIT setting the classifier is a three-layer network of 1024 neurons that takes 11 frames of 26 features and predicts the phone of the centre frame. The classifier trains for 20 epochs and the abnormality module for two. The abnormal training examples are TIMIT utterances distorted by white, brown or pink noise at various volumes, where brown and pink noise are defined by their spectral densities as proportional to 1/f^2 and 1/f.
The noise family used at test time is not the one used in training.
Abnormality module results
On TIMIT the average AUROC of the abnormality module is 97, compared with 80 for the softmax baseline. The Chinese speech row moves from 79 to 90 AUROC. For the MNIST experiments, the abnormality module averages an AUROC of 100 over the five out-of-distribution sets, against 93 for the softmax baseline. The MNIST sets are Omniglot, notMNIST, CIFAR-10bw, Gaussian and Uniform.
The authors explain the speech gap with error rates. The frame classification error of the fully connected network is 29.69% on the full test set, and the average error on distorted examples is 30.43%, so the classifier is barely confused and the softmax statistic is not informative. The abnormality module still separates the Chinese speech examples in that regime, and the authors argue that this matters when an input is out-of-distribution without greatly confusing the network.
Where the baseline and the module fall short
The abnormality module does not beat the softmax baseline on every task, so the gains are on some tasks rather than all. Its scope is limited to the architectures and datasets tested here. For the speech experiments, the abnormality module was trained on THCHS-30 training examples rather than test examples, because fully connected networks could process the whole training set quickly.
Weblog sentences are hard to detect as out-of-distribution, with an AUROC of 61 against 80 for tweets, so the baseline is weakest where the out-of-distribution data resembles the training data. The authors caution that their exact values should not be used as fixed targets for comparison, and that tests should use a variety of tasks and architectures.
Directions the authors suggest
The authors suggest using intra-class distances, so that an example far from others of its predicted class may be out-of-distribution, and feeding per-layer activation summaries into a recurrent network to judge whether they look abnormal. They also suggest separating known unknowns from unknown unknowns, and predicting the probability that a detection is correct.
For evaluation, the authors recommend reporting AUPR and AUROC alongside the classifier's accuracy, because an always-wrong classifier attains a high AUPR for error detection when errors are the positive class. They propose comparing any new detector against a detector built on softmax prediction probabilities from the same classifier.
Paper info
- Authors
- Dan Hendrycks, Kevin Gimpel
- Venue
- arXiv · Preprint
- First published
- 2016-10-7
- Added
- 2026-11-12
- Updated
- 2018-10-3
- Version
- v3
- arXiv
- 1610.02136
- Category
- cs.NE · cs.CV · cs.LG
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Dan Hendrycks, Kevin Gimpel (2016). A Baseline for Detecting Misclassified and Out-of-Distribution Examples in Neural Networks. arXiv:1610.02136v3. https://arxiv.org/abs/1610.02136v3
BibTeX
@misc{hendrycks2016baseline,
title = {{A Baseline for Detecting Misclassified and Out-of-Distribution Examples in Neural Networks}},
author = {Dan Hendrycks and Kevin Gimpel},
year = {2016},
eprint = {1610.02136},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1610.02136v3}
}