NNrepair: Constraint-Based Repair of Neural Network Classifiers

Muhammad Usman, Divya Gopinath, Youcheng Sun, Yannic Noller, Corina S. Pasareanu

TL;DR

This paper introduces NNREPAIR, a novel constraint-based technique for automatically fixing defects in trained neural network classifiers. It can repair networks at either intermediate layers or the final output layer, improving accuracy, fixing security vulnerabilities from data poisoning, and enhancing robustness against adversarial attacks, all without requiring new training data.

What Problem Does This Paper Address?

Neural networks are increasingly used in critical applications, but like any software, they can have defects. These defects can manifest as low overall accuracy, vulnerabilities to malicious data poisoning (where a model performs well on normal data but poorly on specifically crafted "poisoned" data), or susceptibility to adversarial attacks (where small input perturbations lead to incorrect classifications). Traditional methods like retraining can be expensive, time-consuming, and may result in a model that deviates significantly from the original. This paper addresses the need for an efficient and targeted repair mechanism that can fix these diverse issues without extensive retraining.

Methods

NNREPAIR employs a two-stage approach:

  1. Fault Localization: This step identifies potentially faulty network parameters, specifically the weights of incoming edges to neurons. It leverages "activation patterns" (the on/off states of neurons) to infer specifications of correct behavior. For intermediate layers, these patterns act as oracles. For the last layer, the desired output label serves as the oracle.
  2. Constraint Solving for Repair: Once faulty parameters are identified, NNREPAIR uses a constraint solver (specifically Z3) to apply minimal modifications to these weights. This process is guided by "concolic execution," which combines concrete execution with symbolic reasoning to generate repair constraints. The technique decomposes the repair problem into generating "expert" networks for each class, which are then combined to form the final repaired model. This approach allows for both intermediate-layer repair (fixing logic within the network) and last-layer repair (adjusting decision boundaries).

Datasets

The paper evaluates NNREPAIR on two standard image classification datasets:

  • MNIST: Used for digit recognition.
  • CIFAR-10: Used for object recognition.

The authors use these datasets to train and evaluate models in various scenarios, including normal classification, poisoned data scenarios, and adversarial attack scenarios.

Key Insights and Ideas

  • Layer-Agnostic Repair: The ability to repair either intermediate layers or the last layer is a significant advantage. This flexibility allows NNREPAIR to tackle different types of defects more effectively, as some issues might be rooted deeper within the network's logic, while others are closer to the final decision-making process.
  • Activation Patterns as Oracles: Using activation patterns for intermediate layer repair is a novel approach. It allows for localized repair without needing to propagate the final output decision all the way back, making the process more efficient and scalable.
  • Expert Combination Strategy: Decomposing the repair into class-specific "experts" and then combining them is a clever way to manage complexity and potentially improve robustness. The paper explores different combination strategies (Naive, Confidence, Voting, Merged) and F1-filtering to find the best approach.
  • Repair without Retraining: The core value proposition is fixing models without the need for new data or full retraining, which is a major practical advantage.

Key Results

NNREPAIR demonstrated significant improvements across various scenarios:

  • Poisoned Data: Achieved an impressive accuracy improvement of 45.56 percentage points on poisoned MNIST data.
  • Adversarial Attacks: Improved accuracy by 10.40 percentage points on adversarial CIFAR-10 data.
  • Overall Accuracy: Provided small but notable improvements in overall accuracy (e.g., +0.20 percentage points on MNIST-LQ) without retraining.
  • Efficiency: While constraint generation can be time-consuming (15-60 minutes per expert), the repair process itself is generally efficient, and the F1-filtering strategy can significantly reduce inference time overhead for intermediate-layer repairs.

Limitations and Future Work

  • No Formal Guarantees: The authors acknowledge that NNREPAIR's efficacy is evaluated statistically, and it does not provide formal guarantees of improvement, especially for overall accuracy in image classification where formal specifications are scarce.
  • Scalability for Very Large Networks: While the approach is designed for scalability, applying single-layer repair repeatedly or compositionally to handle bugs across multiple layers is suggested for future work on larger networks.
  • Comparison with Retraining: For low-quality models, retraining might yield better results than NNREPAIR, suggesting a need for more comparative studies.
  • Adversarial Attack Coverage: The current work demonstrates feasibility for specific adversarial attacks, but covering all possible attacks remains an open challenge.
  • Determining Optimal Repair Layer: The paper suggests that fault localization techniques could help determine which layer(s) are most suitable for repair in a given application, indicating a direction for future research.

Summary updated

BibTeX
@inproceedings{usman2021nnrepair,
  author = {Muhammad Usman and Divya Gopinath and Youcheng Sun and Yannic Noller and Corina S. Pasareanu},
  title = {{NNrepair: Constraint-Based Repair of Neural Network Classifiers}},
  booktitle = {CAV},
  year = {2021},
  url = {https://openreview.net/forum?id=dAogRA0M1r},
}

Loading related content...

Figure