Testing Deep Neural Network based Image Classifiers

Yuchi Tian, Ziyuan Zhong, Vicente Ordonez, Baishakhi RayarXiv 2019 · DOI

Abstract

Image classifiers are an important component of today's software, from consumer and business applications to safety-critical domains. The advent of Deep Neural Networks (DNNs) is the key catalyst behind such wide-spread success. However, wide adoption comes with serious concerns about the robustness of software systems dependent on DNNs for image classification, as several severe erroneous behaviors have been reported under sensitive and critical circumstances. We argue that developers need to rigorously test their software's image classifiers and delay deployment until acceptable. We present an approach to testing image classifier robustness based on class property violations. We found that many of the reported erroneous cases in popular DNN image classifiers occur because the trained models confuse one class with another or show biases towards some classes over others. These bugs usually violate some class properties of one or more of those classes. Most DNN testing techniques focus on per-image violations, so fail to detect class-level confusions or biases. We developed a testing technique to automatically detect class-based confusion and bias errors in DNN-driven image classification software. We evaluated our implementation, DeepInspect, on several popular image classifiers with precision up to 100% (avg.~72.6%) for confusion errors, and up to 84.3% (avg.~66.8%) for bias errors. DeepInspect found hundreds of classification mistakes in widely-used models, many exposing errors indicating confusion or bias.

Introduction

Deep Neural Networks (DNNs) have revolutionized image classification, enabling human-level performance across diverse applications. However, their deployment in safety-critical domains is often hindered by "model bugs"—systematic errors that lead to high-profile failures. Notable examples include mis-tagging individuals or exhibiting gender bias in activity recognition. While existing software engineering research has focused on per-image violations (e.g., adversarial attacks), there is a critical need for tools that detect class-level violations where entire categories are systematically mishandled.

The Challenge of Class-Level Errors

Current testing methodologies often overlook systematic failures in favor of individual edge cases. We identify two primary types of class-level errors:

  1. Confusion: The model's inability to reliably distinguish between two distinct classes, such as confusing a cello with a violin.
  2. Bias: Disparate outcomes between related groups influenced by a third contextual factor. For instance, a model might correctly identify genders in isolation but misclassify women as men when they are pictured with specific sports equipment like snowboards.

Methodology: DeepInspect

We propose DeepInspect, a novel white-box testing framework designed to identify these systematic bugs by analyzing internal neuron activation patterns. Unlike traditional testing, DeepInspect does not require ground-truth labels for production data, as it leverages the model's own predictions to group images into classes.

Overview of the DeepInspect workflow for detecting confusion and bias errors.

The core of DeepInspect is the Neuron Activation Probability (NAP) metric. Instead of binary tracking of neuron firing (standard neuron coverage), DeepInspect calculates the probability of each neuron activating for a specific predicted class, creating a unique "fingerprint" for that class's internal representation.

To detect confusion, we use the Neuron Activation Probability Vector Distance (NAPVD), which measures the Euclidean distance between these fingerprints. A small distance indicates that the model's internal logic for two classes is nearly identical, signaling a high likelihood of confusion. Bias is detected by analyzing how a "context" class shifts the internal representation of two other classes.

Distributions of confusions and NAPVD used to identify systematic errors.

As shown in the distributions above, DeepInspect identifies errors by looking for outliers beyond a standard deviation threshold. This statistical approach allows the tool to flag systematic failures even in the absence of labels.

Experimental Evaluation

We evaluated DeepInspect across eight settings using major benchmarks, including COCO, imSitu, CIFAR-100, and ImageNet. We also tested "provably robust" models to see if adversarial robustness translates to class-level reliability.

Key Findings

  • High Precision: DeepInspect achieved up to 100% precision for confusion errors in the top 1% of flagged cases on COCO models. Across all datasets, average precision was 72.6% for confusion and 66.8% for bias.
  • Discovery of New Bugs: The tool uncovered hundreds of previously undocumented classification mistakes in widely used pre-trained models.
  • Coverage Limitations: We found that traditional neuron coverage is a poor indicator of model health, as different classes often exhibit similar total coverage. NAP provides a much finer-grained semantic map.
  • Robustness Gap: Models designed to resist adversarial noise still suffered from significant class-level confusion, suggesting that current definitions of "robustness" are too narrow.
  • Contextual "Magnets": Our analysis quantified how certain objects (e.g., surfboards) act as magnets in latent space, pulling the representation of one class (e.g., women) toward another (e.g., men), leading to biased misclassifications.

Conclusion

DeepInspect demonstrates that analyzing internal model representations can effectively identify systematic class-level bugs without requiring labeled data. While the tool currently relies on predefined thresholds and is limited to known classes, it opens the door for automated "debugging and repair" pipelines. Future work will explore integrating DeepInspect with generative models to automatically synthesize training data to fix identified confusions and biases.

Summary updated

BibTeX
@misc{tian2019testing,
  author = {Yuchi Tian and Ziyuan Zhong and Vicente Ordonez and Baishakhi Ray},
  title = {{Testing Deep Neural Network based Image Classifiers}},
  year = {2019},
  eprint = {1905.07831},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1905.07831},
}
Figure