Source-linked AI summary
Training Confidence-calibrated Classifiers for Detecting Out-of-Distribution Samples
Kimin Lee, Honglak Lee, Kibok Lee, Jinwoo Shin
TL;DR
Deep neural networks can be overconfident on out-of-distribution inputs, while threshold-based detectors depend on the quality of the pretrained classifier. The paper jointly trains a confidence-calibrated classifier and an adversarial generator to improve this separation. Across image-dataset experiments, the trained classifier substantially improves threshold-based detection, including large true-negative-rate gains on CIFAR-10 and SVHN.
Problem
Deep neural networks can be overconfident on out-of-distribution inputs, and threshold-based detectors depend strongly on how their classifiers are trained.
Method
The method adds a KL-based confidence loss and jointly trains a classifier with a GAN that generates effective out-of-distribution boundary samples.
Results
The proposed classifier improves all evaluated threshold-based detectors, with VGGNet true negative rate increasing from 14.0% to 39.1% on CIFAR-10 and from 46.3% to 98.9% on SVHN.
Takeaways & Limitations
Training the classifier jointly with an out-of-distribution generator improves threshold-based detection across the reported image-classification experiments.
Takeaways & Limitations
The method samples out-of-distribution data near the in-distribution boundary because covering all possible out-of-distributions is infeasible; the GAN training also assumes a fixed classifier initially.
Abstract
from arXiv · showhide
The problem of detecting whether a test sample is from in-distribution (i.e., training distribution by a classifier) or out-of-distribution sufficiently different from it arises in many real-world machine learning applications. However, the state-of-art deep neural networks are known to be highly overconfident in their predictions, i.e., do not distinguish in- and out-of-distributions. Recently, to handle this issue, several threshold-based detectors have been proposed given pre-trained neural classifiers. However, the performance of prior works highly depends on how to train the classifiers since they only focus on improving inference procedures. In this paper, we develop a novel training method for classifiers so that such inference algorithms can work better. In particular, we suggest two additional terms added to the original loss (e.g., cross entropy). The first one forces samples from out-of-distribution less confident by the classifier and the second one is for (implicitly) generating most effective training samples for the first one. In essence, our method jointly trains both classification and generative neural networks for out-of-distribution. We demonstrate its effectiveness using deep convolutional neural networks on various popular image datasets.
1 INTRODUCTION
The paper frames out-of-distribution detection as a response to overconfident DNN predictions and argues that detector performance depends strongly on classifier training. It proposes training classifiers to separate in- and out-of-distribution samples more effectively.
- Motivation: DNNs can produce highly confident predictions for inputs such as random noise despite achieving high classification accuracy.The paper cites MNIST classifiers assigning 91% confidence to random noise as an example.
- Problem: Out-of-distribution detection determines whether a test input comes from the training distribution or a sufficiently different distribution.The detector assigns 1 to in-distribution inputs and 0 otherwise.
- Prior Work: Prior methods mainly use threshold-based confidence scores computed from pre-trained classifiers, sometimes with temperature scaling and input perturbations.These methods compare a confidence score q(x) against a threshold δ.
- Motivation: Threshold-based detectors depend on classifiers that separate predictive confidence for in-distribution and out-of-distribution samples.The paper therefore emphasizes improving classifier training rather than only modifying inference.
- Contribution: The proposed method adds a confidence loss and a generative adversarial network to train classifiers for improved out-of-distribution detection without losing original classification accuracy.The GAN generates effective boundary samples, while the classifier is trained to make out-of-distribution predictions less confident.
- Results: 14.0% →39.1% and 46.3% →98.9%: VGGNet improves true negative rate on LSUN relative to baseline for CIFAR-10 and SVHN, respectively, at 95% in-distribution detection.The paper reports improvements across all experiments for the evaluated threshold-based detectors.
2 TRAINING CONFIDENT NEURAL CLASSIFIERS
The training framework augments classifier learning with confidence regularization and an adversarial generator that produces effective out-of-distribution samples. The classifier and GAN are optimized alternately so that each improves the other.
- Training Framework: The method trains an improved classifier while retaining prior threshold-based detectors for inference and evaluation.Its goal is to map in- and out-of-distribution samples separately in the output space.
- Confident Classifier: The confidence loss adds a KL-divergence penalty that moves out-of-distribution predictive distributions toward the uniform distribution.In-distribution examples continue to use label-dependent cross-entropy training, while β > 0 controls the penalty.
- Confident Classifier: The resulting classifier is designed to assign higher maximum predictive probabilities to in-distribution samples than to out-of-distribution samples.The intended out-of-distribution behavior is approximately zero confidence.
- Sampling Assumption: Sampling all possible out-of-distributions is infeasible, so the method targets samples close to the in-distribution boundary without assuming a specific test out-of-distribution.The paper describes this sampling choice as potentially more effective for detection.
- Adversarial Generator: The GAN is motivated as an alternative to explicit out-of-distribution sampling and to pretrained density-estimation models for approximating in-distribution density.The paper uses confident classifiers for density approximation in its fully supervised setting.
- Adversarial Generator: The proposed GAN generates low-density boundary samples by combining a classifier-based KL term with an original GAN loss that keeps samples close to in-distribution.The classifier-based term replaces the out-of-distribution distribution in the confidence loss with the generator distribution.
- Joint Optimization: Joint training shares the KL term between classifier and GAN losses, with classifier parameters and GAN parameters optimized alternately.The paper states that the classifier improves the GAN and vice versa during training.
3 EXPERIMENTAL RESULTS
Experiments across image datasets evaluate confidence-based training, generated out-of-distribution samples, threshold detectors, and sensitivity maps. The proposed methods improve separation between in- and out-of-distributions while preserving classification performance in the reported settings.
- CNNs were evaluated on CIFAR, SVHN, ImageNet, LSUN, and synthetic Gaussian-noise distributions using VGGNet and AlexNet classifiers.
- Effects of confidence loss: Confidence loss produced better separation between SVHN and out-of-distributions, including unseen TinyImageNet, LSUN, and synthetic datasets, than cross entropy.
- Effects of confidence loss: VGGNet trained with confidence loss improved detection across out-of-distributions when SVHN was in-distribution without reducing classification performance, whereas explicit SVHN training data did not improve CIFAR-10 detection overall.
- Effects of adversarial generator and joint confidence loss: The proposed GAN generated samples near the low-density boundary of a Gaussian-mixture distribution, unlike the original GAN, which covered high-density regions.
- Effects of adversarial generator and joint confidence loss: The proposed GAN generated less digit-like samples than the original GAN on MNIST while still producing some new digit-like images.
- Effects of adversarial generator and joint confidence loss: Joint confidence loss outperformed confidence loss using explicit out-of-distribution datasets and cross entropy across tested cases without harming classification performance.
- Effects of adversarial generator and joint confidence loss: Cross-entropy models had sharp sensitivity maps for both distributions, whereas confidence-loss models showed sharp maps primarily for in-distribution samples.
4 CONCLUSION
The paper proposes training classifiers to improve out-of-distribution detection while retaining classification accuracy, using threshold-based detectors after training. Its evaluation uses threshold-independent metrics, and the approach jointly trains classification and generative models, with image classification as the main experimental focus.
- The method trains neural classifiers to improve out-of-distribution detection without losing original classification accuracy.
- The approach jointly trains detection and generation models by alternating optimization of their losses, with experiments primarily focused on image classification.
- Threshold-based detectors assign labels by comparing a classifier-derived confidence score q(x) with a threshold δ.
- AUORC and detection accuracy provide threshold-independent evaluation metrics for the detector.
B EXPERIMENTAL SETUPS IN SECTION 3
The experiments evaluate threshold-based out-of-distribution detectors with CNN classifiers on CIFAR-10 and SVHN, using realistic images and synthetic noises as negative samples. Performance is measured with threshold-based detection metrics, while additional experiments examine generated samples.
- Datasets: CIFAR-10 and SVHN test sets serve as in-distribution samples, while TinyImageNet, realistic images, and synthetic noises provide out-of-distribution samples.CIFAR-10 has 50,000 training and 10,000 test images; SVHN has 73,257 training and 26,032 test images.
- Models: VGGNet and AlexNet are trained for image classification, alongside simpler CNNs used in evaluation experiments.The simple CNN has two convolutional layers followed by three fully connected layers; AlexNet has five convolutional and three fully connected layers.
- Metrics: Detection performance is evaluated with TNR at 95% TPR, AUROC, AUPR-IN, AUPR-OUT, and detection accuracy.AUROC, AUPR, and detection accuracy are threshold-independent metrics.
- Assumptions: The experiments assume equal probabilities for in-distribution and out-of-distribution samples in the test set.The stated assumption is P(x is from Pin) = P(x is from Pout) = 0.5.
- Sample generation: Additional sample-generation experiments compare original and proposed GANs on a two-Gaussian example and MNIST.The Gaussian experiment uses fully connected networks, while the MNIST experiment uses DCGANs.
C.1 CLASSIFICATION PERFORMANCES
Classification performance remains essentially unchanged across the tested training losses on CIFAR-10 and SVHN. The reported classification-error differences across tested single models are at most 1%.
- Classification performance: At most 1% separates the classification errors of tested single models across the evaluated training losses.The comparison covers VGGNets on CIFAR-10 and SVHN.
- Classification performance: Table 2 reports VGGNet classification test-set accuracy on CIFAR-10 and SVHN under various training losses.The table concerns classification accuracy rather than out-of-distribution detection metrics.
C.2 CALIBRATION EFFECTS OF CONFIDENCE LOSS
The paper evaluates calibration with expected calibration error (ECE), grouping predictions into confidence bins. Classifiers trained with the proposed methods have lower ECE than those trained with standard cross entropy, with further improvement from temperature scaling.
- Calibration metric: ECE groups predictions into M confidence bins and compares each bin’s accuracy with its confidence.The paper sets M to 20 in Table 3.
- Calibration results: Lower ECE is reported for classifiers trained with the proposed methods than for classifiers trained with standard cross entropy.The paper interprets this as improved calibration of predictions.
- Calibration results: Temperature scaling provides further calibration improvements when applied to a classifier trained with the joint confidence loss.The confidence score is defined as the maximum predictive distribution.
C.3 EXPERIMENTAL RESULTS USING ODIN DETECTOR
The ODIN experiments test temperature scaling and input perturbation with classifiers trained using different losses. The proposed joint confidence loss improves both baseline and ODIN detection performance across evaluated in-distribution and out-of-distribution pairs.
- ODIN procedure: ODIN preprocesses each input with a small perturbation, then thresholds the maximum temperature-scaled predictive probability.The perturbation magnitude ε and temperature T are selected from specified candidate sets using validation detection error.
- ODIN comparison: The baseline detector with joint-confidence-loss classifiers typically outperforms ODIN with cross-entropy classifiers.This indicates improved separation without preprocessing such as temperature scaling.
- ODIN comparison: ODIN achieves further improvements when combined with classifiers trained using the joint confidence loss.The paper concludes that the training method improves prior threshold-based detectors.
C.4 EXPERIMENTAL RESULTS ON ALEXNET
AlexNet experiments compare the baseline and ODIN threshold-based detectors across in- and out-of-distribution pairs. The reported results show similar trends across pairs.
- Results: The detection results for AlexNet show similar trends across the evaluated in- and out-of-distribution pairs.
- Experimental setup: AlexNet experiments evaluate the baseline and ODIN detectors for each in- and out-of-distribution pair.Table 4 reports percentages for both detectors, with seen out-of-distribution data used during training and unseen data used for testing.
D MAXIMIZING ENTROPY
The paper considers maximizing generator entropy to obtain broader out-of-distribution samples, but uses the pull-away term because explicit entropy optimization is technically challenging. Its gains are inconsistent and marginal enough to remain optional.
- Motivation: Maximizing generator entropy is motivated by the larger space expected for out-of-distribution samples, but GANs do not explicitly model generator distributions.The paper identifies explicit entropy maximization as technically challenging.
- Pull-away term: The pull-away term increases entropy implicitly by minimizing squared cosine similarity among generated samples.The term is applied to generated sample representations and is intended to diversify them.
- Results: Joint confidence loss with the pull-away term tends to, but does not always, improve detection performance.The reported gains are relatively marginal or controversial, while the term increases training complexity.
- Conclusion: The pull-away term is retained as an auxiliary option rather than a default component for improving performance.
E ADDING OUT-OF-DISTRIBUTION CLASS
The paper compares confidence loss with adding an explicit out-of-distribution class. Confidence loss often performs better, while explicit modeling can overfit the out-of-distribution dataset used for training.
- Alternative design: An alternative classifier design adds an additional out-of-distribution class instead of making predictions closer to uniform.
- Comparison: Confidence loss often significantly outperforms the alternative that adds a new class label.The comparison uses VGGNets for image classification on SVHN, with CIFAR-10 training data for the additional terms.
- Interpretation: Explicitly modeling out-of-distribution data can incur overfitting to the trained out-of-distribution dataset.
- Evaluation: Table 6 reports baseline and ODIN detection performance using VGGNet, with all values expressed as percentages.