Understanding Classifier Mistakes with Generative Models

Laëtitia Shao, Yang Song, Stefano ErmonarXiv 2020

Abstract

Deep neural networks often exhibit overconfidence in their predictions, even when incorrect. This paper explores a method to detect these failures by fitting a Gaussian Mixture Model (GMM) to the internal feature representations of a classifier. By identifying samples that fall into low-probability regions of the feature space, the proposed approach effectively flags potential mistakes, adversarial attacks, and out-of-distribution data without requiring retraining of the primary model.

Introduction: The Brittle Nature of Deep Learning

Despite achieving state-of-the-art performance across various domains, deep neural networks (DNNs) remain remarkably brittle. They are prone to three primary failure modes: poor generalization on test data due to spurious correlations, extreme vulnerability to adversarial perturbations, and a lack of awareness regarding out-of-distribution (OOD) inputs. A central issue is the lack of proper calibration; modern networks often produce high-confidence scores for incorrect or nonsensical inputs. While previous attempts used complex generative models like PixelCNN to model the input data distribution, these methods are computationally intensive and often fail to align with the classifier's internal logic.

Methodology: Modeling the Feature Space

The authors propose shifting the focus from the high-dimensional input space (pixels) to the lower-dimensional feature space. The process involves:

  1. Feature Extraction: Utilizing a pre-trained classifier to extract activations from the final layer before the softmax operation.
  2. Gaussian Mixture Modeling (GMM): Fitting a GMM to these features using the training set in a class-agnostic manner. This allows the model to learn the distribution of "normal" features across the entire dataset.
  3. Likelihood-Based Detection: At inference time, any input generating a feature vector with a low log-likelihood under the GMM is flagged as a potential failure.
  4. Feature Purification: A "purification" step is introduced where low-probability features are nudged toward higher-probability regions of the GMM via gradient descent, potentially correcting the classifier's initial mistake.

Datasets and Evaluation

The approach was rigorously tested using standard image classification benchmarks, specifically CIFAR-10 and CIFAR-100. To evaluate OOD detection, the researchers used datasets such as SVHN (Street View House Numbers), Tiny ImageNet, and Fashion-MNIST. The experiments were conducted across multiple architectures, including DenseNet-100 and Wide ResNet-28 (WRN).

Sample images from the CIFAR-100 dataset used for evaluation.

Key Insights: Why Features Matter

A critical finding of this research is that misclassified samples consistently reside in the "suburbs" of the feature space—regions with lower probability density. Statistical analysis using the Mann-Whitney U-test confirmed that features of incorrect predictions have significantly lower likelihoods than those of correct ones.

Furthermore, the study highlights the superiority of modeling feature space over pixel space. While a "weird" image might have a low likelihood in pixel space (e.g., via PixelCNN), it might still map to a very "normal" region in the classifier's feature space. Conversely, an adversarial image might look perfectly normal in pixel space but produce anomalous features. By modeling the features directly, the detection mechanism is aligned with the classifier's internal representation.

Comparison of log-likelihood distributions for correct and incorrect samples using PixelCNN (input space) and GMM (feature space).

The researchers also found that simple GMMs often outperform more complex generative models like Variational Autoencoders (VAEs). Highly flexible models may overfit the feature manifold too closely, reducing their ability to distinguish between valid features and anomalous ones.

Experimental Results

  • Mistake Detection: On CIFAR-100, GMM-based detection achieved an AUC-ROC of approximately 84% for Wide ResNet, outperforming PixelCNN and rivaling specialized calibration techniques.
  • Adversarial Defense: The GMM proved highly effective at identifying adversarial attacks (FGSM and BIM). For DenseNet on CIFAR-100, it achieved an AUC-ROC of over 92% for detecting FGSM attacks, a significant improvement over standard logit-based methods.
  • OOD Detection: The GMM consistently surpassed the Mahalanobis score baseline, particularly in semi-supervised settings where labeled data is limited.
  • Accuracy Gains: The "purification" process successfully corrected enough errors to increase the test accuracy of a DenseNet model by 0.6% without any additional training.

Limitations and Future Directions

While promising, the method has limitations. The 0.6% accuracy gain from purification suggests a ceiling; if the original feature extractor is fundamentally flawed, moving features within that space can only provide marginal improvements. Additionally, the method's effectiveness is entirely dependent on the quality of the learned features. Future work will focus on scaling these GMM-based approaches to the massive feature spaces of models trained on full-scale ImageNet.

Summary updated

BibTeX
@misc{shao2020understanding,
  author = {Laëtitia Shao and Yang Song and Stefano Ermon},
  title = {{Understanding Classifier Mistakes with Generative Models}},
  year = {2020},
  eprint = {2010.02364},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2010.02364},
}
Figure