Source-linked AI summary

DeepMutation: Mutation Testing of Deep Learning Systems

Lei Ma, Fuyuan Zhang, Jiyuan Sun, Minhui Xue, Bo Li, Felix Juefei-Xu, Chao Xie, Li Li, Yang Liu, Jianjun Zhao, Yadong Wang

arXiv:1805.05206v2cs.SE

TL;DR

DL test accuracy alone does not establish robustness or generality, and traditional mutation testing does not directly fit DL systems. DeepMutation addresses this gap with source-level and model-level fault injection, evaluating test-data quality through mutant detection. Experiments on MNIST, CIFAR-10, and three DL models demonstrate the techniques’ usefulness.

  • Problem

    DL models can achieve high test accuracy while lacking generality and robustness, while traditional mutation testing cannot be directly applied because DL systems differ fundamentally from conventional software.

  • Method

    DeepMutation injects faults through source-level operators on training data and programs and model-level operators directly on DL models, then evaluates test data by detected mutant behavior differences.

  • Results

    Experiments on MNIST and CIFAR-10 with three DL models demonstrate the usefulness of the proposed mutation-testing techniques for measuring test-data quality.

  • Takeaways & Limitations

    Mutation testing provides a proposed measurement toward designing and constructing higher-quality DL test datasets and potentially facilitating robustness enhancement.

  • Takeaways & Limitations

    The selected datasets and DL models may threaten validity, and randomness in source-level mutant-model training can produce different models from the same training data.

Abstract

from arXiv · show

Deep learning (DL) defines a new data-driven programming paradigm where the internal system logic is largely shaped by the training data. The standard way of evaluating DL models is to examine their performance on a test dataset. The quality of the test dataset is of great importance to gain confidence of the trained models. Using an inadequate test dataset, DL models that have achieved high test accuracy may still lack generality and robustness. In traditional software testing, mutation testing is a well-established technique for quality evaluation of test suites, which analyzes to what extent a test suite detects the injected faults. However, due to the fundamental difference between traditional software and deep learning-based software, traditional mutation testing techniques cannot be directly applied to DL systems. In this paper, we propose a mutation testing framework specialized for DL systems to measure the quality of test data. To do this, by sharing the same spirit of mutation testing in traditional software, we first define a set of source-level mutation operators to inject faults to the source of DL (i.e., training data and training programs). Then we design a set of model-level mutation operators that directly inject faults into DL models without a training process. Eventually, the quality of test data could be evaluated from the analysis on to what extent the injected faults could be detected. The usefulness of the proposed mutation testing techniques is demonstrated on two public datasets, namely MNIST and CIFAR-10, with three DL models.

I. INTRODUCTION

DeepMutation adapts mutation testing to DL systems, whose behavior depends on training data, programs, network structures, and weights. It evaluates test-data quality by measuring detection of faults injected at source and model levels.

  • Motivation: DL robustness and generality cannot be inferred reliably from accuracy on a prepared test dataset alone.The paper identifies systematic evaluation of test-data quality as necessary for confidence in DL systems.
  • Motivation: Traditional mutation testing cannot be directly transferred because DL behavior is shaped by training data, training programs, network structures, and learned weights.Training data and training programs produce the weights that determine much of the model’s behavior.
  • Framework: DeepMutation evaluates test-data quality by generating mutants and checking whether candidate tests detect output differences between original and mutated DL models.A test input detects a mutant when the original and mutant models produce inconsistent outputs; more detected differences indicate higher test-data quality.
  • Framework: The framework combines eight source-level operators on training data and programs with eight model-level operators that inject faults directly into DL models.Model-level mutation avoids retraining and supports efficient generation of many fine-grained mutants.
  • Evaluation: The framework includes two DL-specific metrics for quantitative measurement of test quality and was evaluated on MNIST, CIFAR-10, and three DL models.The evaluation is presented as demonstrating usefulness for designing and constructing higher-quality test datasets.

II. BACKGROUND

DL software uses a data-driven programming paradigm in which training data and programs shape a neural network’s encoded logic. This differs fundamentally from traditional software, whose developer-written source code specifies decomposable logic units.

  • A. Programming Paradigms: Traditional software implements developer-crafted logic in source-code units such as classes, methods, statements, and branches.These units can be tested as targets of software-quality measurements such as statement and branch coverage.
  • A. Programming Paradigms: DL software programs core logic through model training using large amounts of data, with logic encoded in neural-network weights and nonlinear activation functions.Developers collect training data specifying desired behavior and prepare a training program describing network structure and runtime training behavior.
  • A. Programming Paradigms: The source-level mutation-testing workflow for DL systems targets the training data and training program rather than only conventional executable code.This workflow reflects the data-driven construction process described for DL software.

B. Mutation Testing

Mutation testing evaluates test-data quality by injecting faults into software and measuring whether tests detect the resulting behavioral differences. DeepMutation applies this principle to DL sources and models through specialized operators and metrics.

  • B. Mutation Testing: Traditional mutation testing creates faulty program mutants by applying predefined operators that slightly modify an original program.For example, an operator may replace a ‘+’ operator with ‘−’.
  • B. Mutation Testing: Tests are first filtered by executing the complete test set on the original program, retaining passed tests for mutant analysis.A mutant is killed when a retained test exposes behavior different from the original program.
  • B. Mutation Testing: Mutation score is traditionally the ratio of killed mutants to all generated mutants and indicates test-set quality.The paper notes that this metric is inappropriate for DL systems because large test sets can kill mutants easily and reduce precision.
  • B. Mutation Testing: DeepMutation introduces source-level operators that modify DL training data or training programs to create mutated inputs for retraining.The source-level workflow applies operators to generate D′ and P′, then trains mutated models for testing.
  • B. Mutation Testing: The framework defines quantitative mutation-testing metrics for evaluating DL test-data quality and uses data and program mutation operators to introduce potential faults.Training-data operators reflect potential collection problems and may apply globally or locally within a dataset.

1) Data Mutation Operators:

The framework mutates training data and programs to simulate faults that can arise during DL system development. Its data operators cover duplication, labeling, deletion, ordering, and noise, while related program operators alter layers and activations.

  • Data Mutation Operators: Data Repetition duplicates a small portion of training data to simulate repeated collection from similar sources.
  • Data Mutation Operators: Label Error changes labels on training examples to simulate mislabeled data.
  • Data Mutation Operators: Data Missing removes training examples, representing inadvertent or mistaken deletion during data preparation.
  • Data Mutation Operators: Data Shuffle changes training-data order because training procedures can be sensitive to presentation order.
  • Data Mutation Operators: Noise Perturbation adds random perturbations to training data, such as pixel noise in images.
  • Program Mutation Operators: Source-level program operators include layer removal, layer addition, and activation-function removal, with structural compatibility restrictions for layer changes.

C. Mutation Testing Metrics for DL Systems

DL mutation testing evaluates test data using class-sensitive mutant behavior rather than the traditional mutant-count score alone. It filters incorrect original-model cases, controls mutant quality by error rate, and highlights sensitive regions near decision boundaries.

  • Metric Setup: Only test points correctly handled by the original model are evaluated against generated mutant models.
  • Mutation Score: A test point kills a mutant class when the original model correctly assigns that class but the mutant does not.
  • Mutation Score: The DL mutation score aggregates the classes killed across mutants and normalizes by the number of mutants and classes.
  • Mutant Quality Control: Mutants with excessively high error rates on the filtered test data are excluded because they differ too greatly from the original model.
  • Average Error Rate: Average error rate measures the overall behavioral difference introduced by mutation operators across mutant models.
  • Interpretation: Data near the original decision boundary are more likely to kill mutant models, increasing the mutation score and average error rate.

IV. MODEL-LEVEL MUTATION TESTING OF DL SYSTEMS

Model-level mutation testing directly modifies trained DL models instead of retraining models after changing training data or programs. The approach uses eight operators spanning weights, neurons, activations, and layers to generate mutants more efficiently.

  • Workflow: Model-level mutation testing targets the trained model M, avoiding the source-level changes to training data D and program P.
  • Workflow: The workflow filters test inputs through the original model before running the correctly processed data on each generated mutant.
  • Motivation: Direct model modification is expected to improve mutant-generation efficiency by avoiding the training procedure.
  • Weight-level Operators: Gaussian Fuzzing samples a weight from N(w, σ^2), with 99.7% probability placing it within [w −3σ, w + 3σ].
  • Neuron-level Operators: Weight Shuffling randomly exchanges a neuron's connection weights, while Neuron Effect Blocking resets outgoing connection weights to zero.
  • Neuron-level Operators: Neuron Activation Inverse changes a neuron's pre-activation output sign, and Neuron Switch exchanges two neurons within a layer.
  • Layer-level Operators: Layer Deactivation, Layer Addition, and activation-function removal alter layer transformations under input-output shape constraints where required.

V. EVALUATION

DeepMutation was implemented with Keras and TensorFlow and evaluated on two practical datasets and three DL model architectures. The supplied passages describe the evaluation scope but report no outcome values.

  • Implementation: DeepMutation implements source-level and model-level mutation testing techniques using Keras with a TensorFlow backend.
  • Evaluation Subjects: The evaluation uses two practical datasets and three DL model architectures to demonstrate the proposed framework's usefulness.

A. Subject Dataset and DL Models

The evaluation uses MNIST and CIFAR-10 with three DL models, while controlled datasets vary sampling scope and class balance to assess test-data quality. Candidate datasets are filtered through original models before mutation analysis.

  • MNIST contains 60,000 training and 10,000 test images across 10 digit classes, while CIFAR-10 contains 50,000 training and 10,000 test images across 10 classes.
  • The study evaluates three DL models with 107,786, 694,402, and 1,147,978 trainable parameters.
  • Controlled settings sample approximately 10% of either original training data or accompanied test data.
  • Each setting pairs uniformly sampled data covering all classes with non-uniformly sampled data focused mainly on a single class.
  • Passed candidate data generate 30 dataset pairs across two settings, three models, and five repetitions.

2) DL Mutant Model Generation:

The framework generates source-level and model-level DL mutants, executes passed candidate data against them, and evaluates test data using average error rate and mutation score. Results favor uniformly sampled data, while dataset size and mutation level can change outcomes.

  • DL Mutant Model Generation: Source-level mutation retrains models after mutating 1% of training data or applying program-level operators, whereas model-level mutation directly alters sampled weights, neurons, or eligible layers.
  • DL Mutant Model Generation: The execution phase runs passed candidate data on mutant models and calculates mutation score and average error rate after filtering high-error mutants.
  • Results: Average error rates range from 0.13% to 17.20%, with uniformly sampled data achieving higher average error rates in all controlled settings.
  • Results: Uniform sampling also produces higher averaged mutation scores across all controlled data-pair settings.
  • Results: For source-level testing of model B, 1,000 uniformly sampled test data yield 0.66% AER versus 0.49% for 5,000 uniformly sampled training data.
  • Results: The same 1% mutation ratio produces different mutation scores for source-level and model-level testing, including lower scores for model A but higher scores for model B at source level.
  • Results: Many cases still have low mutation scores, indicating low-quality evaluated tests in the studied high-dimensional setting.

D. Mutation Testing of Original Test Data by Class

The study evaluates original test data separately by class to examine whether different classes provide different mutation-testing evidence for DL models.

  • For MNIST and CIFAR-10, the accompanied test data are separated into ten class-specific datasets and filtered on models A, B, and C.
  • Class-specific test data can obtain different mutation scores and average error rates across models.

1) Test Data and Mutant Models:

Class-level mutation testing identifies differences in the testing value of data from individual classes and supports targeted enhancement of weak test data. The study also notes dataset and model selection as a validity threat.

  • Mutation Testing Results of Test Data by Class: For model A, class 3 has the lowest mutation score and AER, at 6.25% and 1.48%, respectively.
  • Mutation Testing Results of Test Data by Class: A higher AER does not necessarily produce a higher mutation score: model A’s class 1 has larger AER but smaller mutation score than class 2.
  • Mutation Testing Results of Test Data by Class: Mutation testing quantitatively analyzes test-data quality by class and helps localize weak data.
  • Threats To Validity: The paper identifies the selection of subject datasets and DL models as a threat to validity.
  • Mutation Testing of Traditional Software: DeepMutation is presented as the first DL mutation-testing framework combining source-level and model-level mutators.

B. Testing and Verification of DL Systems

Existing DL testing and verification techniques address aspects such as adversarial-example generation and safety-property verification, while DeepMutation introduces mutation testing to evaluate DNN test-data quality. The framework applies source-level and model-level fault injection and is demonstrated on MNIST and CIFAR-10 with three DL models.

  • Existing DL testing mainly probes accuracy, while DeepXplore generates adversarial examples to achieve neuron coverage through white-box differential testing.
  • VERIVIS verifies DNN safety properties under specified input transformations, but its transformations remain simpler than potential real-world transformations.
  • Formal verification for DNNs is promising, yet most demonstrations use simple architectures, leaving scalable verification for complex real-world networks as an open direction.
  • DeepMutation is presented as mostly orthogonal to existing testing and verification because it systematically evaluates DNN test-data quality through mutation testing.
  • The framework injects faults into training data, training programs, and trained models, then uses mutation-testing metrics to measure test-data quality.
  • The paper describes this work as an initial exploratory attempt and identifies broader mutation operators and human-fault comparability as future work.
Loading 1805.05206v2…