Tutorials on Testing Neural Networks

Nicolas Berthier, Youcheng Sun, Wei Huang, Yanghao Zhang, Wenjie Ruan, Xiaowei HuangarXiv 2021

As machine learning (ML) models are increasingly integrated into safety-critical systems—ranging from autonomous vehicles to medical diagnostics—the lack of rigorous, formal testing methods has become a significant vulnerability. Unlike traditional software, where logic is explicitly programmed and can be verified through standard code coverage metrics, neural networks function as "black boxes" with logic distributed across millions of weights and biases. This fundamental difference renders traditional software engineering (SE) metrics obsolete.

In "Tutorials on Testing Neural Networks," Berthier et al. address this gap by introducing a suite of open-source tools—DeepConcolic, TestRNN, EKiML, and GUAP. These tools adapt established SE concepts, such as coverage-guided testing, to the unique architectures of Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Random Forests.

Methodologies for ML Testing

The authors propose a unified toolkit designed to evaluate model robustness and security through four distinct frameworks:

1. DeepConcolic (CNNs and Feed-Forward Networks)

DeepConcolic implements coverage-guided testing to generate adversarial examples. It measures "coverage" by tracking neuron activation states or high-level features extracted via Principal Component Analysis (PCA) and Bayesian Networks. The tool employs concolic execution, which combines concrete execution with symbolic Linear Programming (LP) solvers to systematically explore the model's state space and identify edge cases that trigger previously unactivated neurons.

2. TestRNN (LSTMs and RNNs)

Testing sequential models requires accounting for temporal dynamics. TestRNN introduces temporal coverage (tracking patterns of memorized values over time) and step-wise coverage (measuring changes in neuron outputs across consecutive time steps). It utilizes random sampling and genetic algorithms to generate test sequences that exercise the internal logic of the RNN.

3. EKiML (Random Forests)

Focusing on security, EKiML (Embedding Knowledge in Machine Learning) explores the susceptibility of tree-based models to poisoning and backdoor attacks. It provides a framework to embed "malicious knowledge" (triggers) into decision trees and, conversely, to synthesize and extract suspected triggers from compromised models.

4. GUAP (Generalizing Universal Adversarial Attacks)

GUAP focuses on the generation of universal adversarial perturbations—single attack patterns that can fool a classifier across an entire dataset. This framework supports both additive noise and spatial transformations, moving beyond image-specific attacks to evaluate broader model vulnerabilities.

Experimental Evaluation

The toolkit was evaluated using several benchmark datasets to demonstrate its versatility across different data modalities:

  • Fashion-MNIST: Used to test CNNs, RNNs, and universal perturbations on complex image data.
  • UCI-HAR (Human Activity Recognition): Used to demonstrate testing on non-image sensor data, which requires maintaining physical plausibility.
  • CIFAR-10 & ImageNet: Standard benchmarks for evaluating universal perturbations via GUAP.

Key Results

  • Efficiency in RNN Testing: TestRNN generated 10,000 test cases for a Fashion-MNIST LSTM in under 10 minutes, identifying hundreds of unique adversarial examples while meeting strict temporal coverage requirements.
  • Backdoor Vulnerability: EKiML demonstrated that a backdoor could be embedded in a HAR decision tree with 100% attack success rate, while maintaining 92.8% accuracy on clean data, making the attack difficult to detect.
  • Spatial Attacks: GUAP successfully reduced target model accuracy to approximately 20% by focusing perturbations on image regions with sharp magnitude changes.

Insights and Future Directions

A critical finding of this research is that while coverage metrics can be translated from traditional SE to ML, they require significant abstraction. For instance, testing every neuron is often less effective than testing the "high-level features" the network has learned. Furthermore, the authors highlight the necessity of "domain-specific oracles." While pixel-wise perturbations are generally valid for images, sensor data (like HAR) requires post-filters, such as Local Outlier Factor (LOF), to ensure generated test cases remain physically realistic.

Despite these advancements, challenges remain regarding the scalability of concolic execution. The Linear Programming problems generated by DeepConcolic grow linearly with network depth, making the testing of very deep architectures computationally expensive. Future work aims to integrate naive fuzzing with symbolic engines to improve the efficiency of vulnerability discovery in deep neural networks.

Summary updated

BibTeX
@misc{berthier2021tutorials,
  author = {Nicolas Berthier and Youcheng Sun and Wei Huang and Yanghao Zhang and Wenjie Ruan and Xiaowei Huang},
  title = {{Tutorials on Testing Neural Networks}},
  year = {2021},
  eprint = {2108.01734},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.01734},
}
Figure