DeepXplore: Automated Whitebox Testing of Deep Learning SystemsDeepXplore: Automated Whitebox Testing of Deep Learning Systems
The authors propose the white-box testing framework DeepXplore, which jointly optimizes neuron coverage and differential testing to generate test inputs, and finds thousands of erroneous behaviors on 15 DNNs.
- Deep learning systems in safety-critical scenarios (autonomous driving, malware detection) often exhibit erroneous behavior on rare corner inputs, while existing testing relies on manual labeling and has low coverage, making it difficult to systematically expose these problems.
- The authors propose the white-box framework DeepXplore: it defines neuron coverage to measure test adequacy, uses multiple DNNs with similar functionality as differential oracles for each other in place of manual labeling, formulates "maximizing behavioral difference + maximizing neuron coverage" as a joint optimization problem, solves it with gradient ascent, and supports domain constraints.
- Found thousands of erroneous behaviors on 5 datasets and 15 DNNs; the neuron coverage of generated inputs is on average 34.4% and 33.2% higher than that of random and adversarial inputs, respectively; generates an input exposing erroneous behavior in 1 second on average; augmenting training data with them improves accuracy by up to 3%.
- The authors note that differential testing requires at least two DNNs with the same functionality, and cannot detect errors when all DNNs under test make the same mistake; the experiments cover 5 datasets and 15 DNNs, hyperparameters are chosen empirically, and the paper reports no statistical significance tests.
- Evaluated models
- LeNet-1LeNet-4LeNet-5VGG-16VGG-19ResNet50DAVE-origDAVE-norminitDAVE-dropoutPDF_C1PDF_C2PDF_C3APP_C1APP_C2APP_C3
- Benchmarks
- MNISTImageNetDriving (Udacity self-driving car challenge)Contagio/VirusTotalDrebin
- Metrics
- neuron coveragecode coveragenumber of difference-inducing inputsexecution timeclassification accuracy
Researchers including Kexin Pei designed and implemented DeepXplore, which the authors describe as the first white-box framework for systematically testing real deep learning systems, finding thousands of erroneous behaviors across 15 state-of-the-art DNNs. The framework proposes neuron coverage to measure the model logic covered by test inputs, uses multiple functionally similar models as mutual references for differential testing to determine erroneous behaviors without manual labeling, and formulates test input generation as a joint optimization problem solved with gradient ascent. On models trained on five datasets—ImageNet, Udacity self-driving, MNIST, Drebin and Contagio/VirusTotal—it generates a test input exposing erroneous behavior on an ordinary laptop at an average of one per second; for example, slightly dimming the image makes the Nvidia DAVE-2 driving model turn right and crash into a guardrail. The generated inputs have neuron coverage on average 34.4% and 33.2% higher than the same number of random inputs and adversarial inputs, can improve classification accuracy by up to 3% when used to retrain models, and can also help identify potentially poisoned training data.
Why it was selectedThe paper proposes the neuron coverage metric and uses multiple similar models as mutual references to find erroneous behaviors of deep learning systems in safety-critical scenarios without manual labeling.
Paper analysis
What problem does this paper attempt to solve?
How to systematically test large-scale DL systems without manual labeling and expose their erroneous behavior on corner cases.
Core problem: how to automatically and systematically test large-scale deep learning systems and discover their erroneous behavior on rare corner inputs, without relying on manual labeling.
- Scenario and importance: DL systems have been deployed in safety-critical domains such as autonomous driving, malware detection, and aircraft collision avoidance, and their erroneous behavior on corner cases may cause serious consequences; the authors cite a Google self-driving car hitting a bus and a Tesla Autopilot hitting a trailer, and state that these corner cases are not in the test set.
- Shortcomings of existing methods: the authors state that existing practice relies on collecting and manually labeling real data, or on generating data with unguided simulation, and cannot cover the huge input space; adversarial example methods can only make small imperceptible perturbations and require manual inspection, and the DL logic they cover is also limited (§6 states that adversarial inputs cover only 52.3% of the logic).
- Core observation: the authors found that random test inputs can achieve 100% code coverage but less than 10% neuron coverage, indicating that code coverage is unsuitable for measuring DL test adequacy; multiple DL systems with similar functionality can serve as cross-referencing oracles for each other, eliminating manual inspection.
- Proposed approach: DeepXplore—the authors state it is the first white-box testing framework for real large-scale DL systems, proposes the neuron coverage metric, replaces manual labeling with differential testing, formulates "triggering differential behavior + high neuron coverage" as a joint optimization problem, and solves it with gradient search.
- Threat model: this paper is not an attack paper and has no explicit threat model; the relevant settings are as follows:
- Tester knowledge: whitebox, with access to the weights of pretrained DNNs and the output values of intermediate-layer neurons.
- Test subjects: pretrained DNNs (image classification, steering angle regression, PDF/Android malware detection).
- Input control: modify inputs starting from unlabeled seed inputs, and domain constraints (lighting, occlusion, only adding features, etc.) can be imposed to ensure inputs are realistic and valid.
- Error determination: multiple similar DNNs producing inconsistent outputs for the same input is treated as potential erroneous behavior, requiring no manual labels.
What related research exists?
Related work falls into four groups: adversarial deep learning, DNN testing and verification, other applications of DNN gradients, and traditional software differential testing.
Adversarial deep learning
- Goodfellow et al. [26], Szegedy et al. [72], Nguyen et al. [49], etc.—deceive DNNs by adding small perturbations imperceptible to humans to inputs. The paper states that such methods have low neuron coverage (Figure 9) and are limited to imperceptible perturbations, with larger perturbations requiring manual inspection; DeepXplore uses differential testing to produce visible but realistic modifications such as lighting and occlusion.
- Adversarial/privacy work in the security community [12, 21, 22, 55, 63, 74, 82]—studies machine learning from security and privacy perspectives; the paper cites them only as background.
DNN testing and verification
- Traditional practice [81] and autonomous driving simulation [2, 4]—measuring accuracy on manually labeled data or performing unguided simulation; the paper states that black-box testing without understanding model internals struggles to find corner cases that induce errors.
- Work on improving DNN robustness [9, 13, 17, 30, 46, 51, 53, 62, 84, 89, 90]—the paper notes that they focus only on adversarial inputs and rely on manually provided ground truth labels.
- Formal verification [32, 37, 57]—verifying whether DNNs satisfy safety properties; the paper notes that it is difficult to scale to real large-scale DNNs, whereas DeepXplore can find erroneous behavior in large models but provides no property guarantees.
Other applications of DNN gradients
- Gradients are used for visualizing intermediate-layer activations [44, 65, 87], style transfer [24, 43, 59], etc.; this paper instead uses gradient ascent to solve a joint optimization problem.
Traditional software differential testing
- Differential testing has been used for JVMs [14], C compilers [45, 86], SSL/TLS certificate validation [11, 15, 56, 67], PDF readers [56], aerospace software [28], mobile apps [36], and web application firewalls [6]; the paper states that its advantage when applied to DNNs is that the objective can be written as a differentiable joint optimization problem and solved efficiently with gradients.
Baselines and benchmarks: the comparison baselines are random selection (random) and adversarial testing (adversarial testing [26]); evaluation uses five datasets: MNIST, ImageNet, Driving (Udacity), Contagio/VirusTotal, and Drebin.
The authors position this paper as: the first white-box testing framework for large-scale real DL systems, with higher coverage and no manual labeling compared with adversarial example work, and able to scale to large models but without providing guarantees compared with formal verification.
How does the paper address this problem?
Formulates "maximizing behavioral differences among DNNs + maximizing neuron coverage" as a joint optimization problem, and uses gradient ascent to generate tests from seed inputs.
Overall approach: DeepXplore uses unlabeled inputs as seeds, and under white-box access uses gradient ascent to simultaneously maximize behavioral differences among multiple similar DNNs and neuron coverage, while applying domain constraints to ensure inputs are realistic.
Problem setup and core definitions
- Neuron coverage: the proportion of distinct neurons activated (output value exceeding threshold t) out of the DNN's total neurons; the authors compare it to code coverage in traditional software.
- Gradient: the DNN is differentiable with respect to the input, and G = ∇x f(θ, x) = ∂ y/∂ x gives the gradient of neuron outputs with respect to the input, computable layer by layer via the chain rule, with the same dimensions as the input; white-box access to weights and intermediate-layer outputs makes computation efficient.
- Differential oracle: when multiple DNNs with the same functionality, trained independently, produce inconsistent outputs for the same input, at least one may be wrong, without needing human labels.
Joint optimization objective
- Objective one (differential behavior): randomly select a DNN F_j and maximize obj1(x) = Σk ≠ j Fk(x)[c] − λ1 Fj(x)[c], i.e., raise the probability that the other DNNs classify x as the original class c and lower that probability for F_j.
- Objective two (neuron coverage): each iteration randomly picks an unactivated neuron n and maximizes its output fn(x) to exceed threshold t; the authors say activating only one neuron per iteration is for clarity.
- Joint objective: objjoint = (Σi ≠ j Fi(x)[c] − λ1 Fj(x)[c]) + λ2 · fn(x); both terms are differentiable, and gradient ascent iteratively modifies x until the DNNs' predictions disagree or the target coverage is reached.
Domain constraints and hyperparameters
- Constraint implementation: the authors say most constraints are hard to embed in the optimization via Lagrange multipliers, so they use a rule-based method that directly modifies the gradient so that the input still satisfies the constraints after each update step; discrete features have their gradients rounded.
- Image constraints: (1) lighting—all pixels increased or decreased together; (2) a single small rectangular occlusion; (3) multiple small black square occlusions (only decreasing pixel values).
- Malware constraints: Drebin modifies only manifest features and only adds, never deletes (to keep app functionality unchanged); Contagio/VirusTotal follow the feature restrictions of Šrndic et al. [79].
- Four hyperparameters: λ1 balances lowering a single DNN against maintaining the other DNNs' predictions; λ2 balances differential behavior and coverage; s is the gradient ascent step size; t is the neuron activation threshold.
Algorithm flow and implementation
- Flow (Algorithm 1): loop indefinitely over the seed set → require all DNNs to predict consistently on the seed → randomly select one DNN as the one to lower → iteratively compute the joint objective gradient, apply constraints, update x → when the DNNs' predictions diverge, record that input and update coverage tracking.
- Implementation: based on TensorFlow 1.0.1 and Keras 2.0.3, about 7,086 lines of Python, without modifying the framework; uses TensorFlow's sub-DNN functionality to extract intermediate-layer outputs and compute gradients.
- Runtime environment: Ubuntu 16.04 laptop (i7-6700HQ, 16GB memory, GTX 1070 GPU).
What experiments did the paper conduct?
Evaluated on 5 datasets and 15 DNNs: finding differential inputs, coverage comparison, runtime efficiency, hyperparameter effects, retraining, and contamination detection.
Experimental setup
- DNNs under test: 15 in total, 3 per dataset—LeNet-1/4/5 on MNIST (MNI_C1–C3, 52–268 neurons); VGG-16/VGG-19/ResNet50 on ImageNet (IMG_C1–C3, 14,888–94,059 neurons); DAVE-orig/DAVE-norminit/DAVE-dropout on Driving (DRV_C1–C3); 3 self-built fully connected DNNs on Contagio/VirusTotal (PDF_C1–C3); 3 DNNs with the architecture of Grosse et al. [29] on Drebin (APP_C1–C3) (Table 1).
- Datasets: MNIST (60,000 training/10,000 test), ImageNet (more than 10,000,000 labeled images), Udacity Driving (101,396 training/5,614 test), Contagio/VirusTotal (5,000 benign + 12,205 malicious PDFs for training), Drebin (129,013 Android apps, 66% for training).
- Baselines: random selection (random) and adversarial testing (adversarial testing [26]).
- Metrics: number of difference-inducing inputs, neuron coverage, code coverage (Python line coverage), generation time, accuracy after retraining.
- Protocol: 2,000 seed inputs randomly selected for each DNN; hyperparameters per Table 2 (λ1=1 or 2, λ2=0.1 or 0.5, t=0), which the authors state were chosen empirically; except for Figure 8, vision tasks use only lighting constraints.
- Number of repetitions: runtime experiments are averaged over 10 runs (Table 8–11); similar-model experiments are averaged over 100 seeds (Table 12).
Main results
Table 2: number of difference-inducing inputs found for each DNN under 2,000 seeds (t=0).
DNN Number of differential inputs found MNI_C1 / C2 / C3 1,073 / 1,968 / 827 IMG_C1 / C2 / C3 1,969 / 1,976 / 1,996 DRV_C1 / C2 / C3 1,720 / 1,866 / 1,930 PDF_C1 / C2 / C3 1,103 / 789 / 1,253 APP_C1 / C2 / C3 2,000 / 2,000 / 2,000 - The authors state that DeepXplore finds thousands of erroneous behaviors on all DNNs under test, generating an input exposing erroneous behavior in 1 second on average.
- The authors state that the neuron coverage of generated inputs is on average 34.4% higher than random inputs and 33.2% higher than adversarial inputs (Figure 9, with the number of inputs equal to 1% of the original test set).
- Exception: the numbers of differential inputs found for MNI_C1 and MNI_C3 (1,073, 827) are notably fewer than for MNI_C2 (1,968) on the same dataset; the paper does not explain why.
Effectiveness of neuron coverage
- Comparison with code coverage: 10 random inputs achieve 100% code coverage for all DNNs, whereas neuron coverage does not exceed 34% for any (e.g., ImageNet C3 only 0.3%, Table 6); the authors state that neuron coverage is a better adequacy metric.
- Effect on diversity of differential inputs: on MNIST, λ2=1 produces differential inputs with a larger average L1 distance than λ2=0 (e.g., experiment 1 rises from 237.9 to 283.3), but fewer differential inputs (871 down to 776) (Table 5); the authors state that the coverage objective makes differences more diverse rather than repetitions of the same root cause.
- Inter-class neuron overlap: on LeNet-5, the average overlap of activated neurons for input pairs from different classes is 45.9, and for the same class is 74.2 (Table 7, 100 pairs each); the authors state this supports that neuron coverage can estimate the number of activated rules.
Performance and hyperparameters
- Time to reach 100% coverage (excluding fully connected layers, Table 8): MNIST 6.6–7.6 s, ImageNet 42.7–45.3 s, Driving 9.8–12.3 s, VirusTotal 23.2–31.1 s, Drebin 152.9–196.4 s.
- Hyperparameter effects (time to generate the first differential input, averaged over 10 runs): the optimal s and λ1 vary by dataset (Table 9, 10), and λ2=0.5 is fastest on all datasets (Table 11).
- Similar-model testing: the smaller the difference between LeNet-1 variants, the more iterations are needed to find the first differential input; when the difference in number of training samples is 0 or 1, it times out within 1000 iterations (Table 12); the authors state that in practice multiple different DNNs are easy to obtain.
Retraining and contamination detection
- Augmented training: retraining 5 epochs with 100 generated inputs added each, the authors report that DeepXplore yields 1–3% more average accuracy improvement than random/adversarial augmentation (Figure 10, LeNet-1/4/5).
- Contamination detection: on contaminated MNIST where 30% of "9"s are mislabeled as "1", using generated inputs to match the training set by structural similarity, the authors report correctly identifying 95.6% of contaminated samples.
Other ablations and analyses
- Neuron coverage on the full MNIST test set (10,000 samples): C1 57.7%, C2 76.4%, C3 83.6%; the full Contagio/VirusTotal test set reaches 100% (§7.1).
- As threshold t increases, coverage decreases for all three methods (Figure 9).
- Tables 3 and 4 each show the top-3 features modified in 2 Drebin/PDF malware samples (examples only, not statistical results).
What are some points that can be further explored?
The authors point out two inherited limitations of differential testing; the experiments cover 5 datasets and 15 DNNs, and no statistical tests are reported.
Limitations noted by the authors and future directions
- Requires multiple DNNs with the same functionality (§8 Limitations): differential testing requires at least two DNNs with the same functionality; if the two differ by only a few neurons, finding difference-inducing inputs is slower (Table 12). The authors say that in practice developers often train DNNs separately and can in most cases obtain multiple models.
- Cannot find common errors (§8 Limitations): if all DNNs under test make the same error, DeepXplore cannot generate a corresponding test case; the authors say that because each DNN is built and trained independently, the probability of the same error in practice is low.
- Provides no property guarantees (§9): compared with formal verification, DeepXplore can find erroneous behavior in large models but cannot guarantee whether a given DNN satisfies a given safety property.
- Fix direction is only preliminary evidence (§2.1): the authors say this paper focuses mainly on automatically finding erroneous inputs, and provides only preliminary evidence (§7.3) on using these inputs to augment or filter training data to fix behavior.
Scope of experiments
- The subjects are 15 DNNs on 5 datasets, covering image classification, steering angle regression, PDF and Android malware detection (Table 1).
- The difference-inducing input search uses 2,000 random seeds per DNN; runtime experiments are repeated 10 times and averaged, and similar-model experiments use 100 seeds (§7, Table 8–12).
- Except for Figure 8, which shows three image constraints, the remaining vision task experiments use only the lighting constraint (§7).
- Retraining experiments are conducted only on MNIST's LeNet-1/4/5, adding 100 generated samples per model and training for 5 epochs (§7.3).
- The paper does not report statistical significance tests; hyperparameters were chosen empirically (§7); the majority voting labels used in retraining assume that the decision of the majority of DNNs is more likely correct (§7.3).
Summarize the main content of the paper
DeepXplore uses neuron coverage plus differential testing for white-box DL testing, finding thousands of erroneous behaviors across 15 DNNs.
A paper on automated testing of deep learning systems: the authors propose a white-box framework, DeepXplore, addressing the problems that DL testing relies on human labels, has low coverage, and struggles to expose erroneous behavior in corner cases.
- Method highlights: defines neuron coverage to measure test adequacy; uses multiple DNNs with the same functionality as mutual differential oracles in place of human checking; formulates "maximizing behavioral differences among DNNs + maximizing neuron coverage" as a joint optimization problem, using gradient ascent to generate inputs from unlabeled seeds; applies domain constraints (lighting, occlusion, add-only features, etc.) in a rule-based manner to ensure inputs are realistic.
- Erroneous behavior discovery: on 15 DNNs across five datasets—MNIST, ImageNet, Driving, Contagio/VirusTotal, and Drebin—with 2,000 seeds, each DNN found 789–2,000 difference-inducing inputs (Table 2); the authors say an input exposing erroneous behavior can on average be generated within 1 second.
- Coverage advantage: the neuron coverage of generated inputs is on average 34.4% higher than random inputs and 33.2% higher than adversarial inputs (Figure 9); 10 random inputs suffice to reach 100% code coverage while neuron coverage is below 34%, and the authors say neuron coverage is better suited to measuring DL test adequacy (Table 6).
- Efficiency: time to reach 100% neuron coverage (excluding fully connected layers) ranges from 6.6–7.6 s on MNIST to 152.9–196.4 s on Drebin (Table 8).
- Downstream applications: augmenting training with generated inputs (100 samples per model, 5 epochs), the authors report 1–3% higher average accuracy than random/adversarial augmentation; in the contamination detection experiment, 95.6% of contaminated samples were correctly identified.
- Authors' conclusion: the authors say DeepXplore is the first white-box testing framework for large-scale real DL systems; they also note that it inherits the limitations of differential testing—it requires multiple DNNs with the same functionality, cannot find common errors across all DNNs, and provides no formal property guarantees.