Refactoring Neural Networks for Verification

David Shriver, Dong Xu, Sebastian G. Elbaum, Matthew B. DwyerarXiv 2019

Introduction

As Deep Neural Networks (DNNs) are increasingly deployed in safety-critical domains such as autonomous driving and unmanned aerial vehicle (UAV) navigation, the need for formal guarantees of their behavior becomes paramount. We require mathematical certainty that a car will not steer erratically or that a drone will avoid collisions under specific constraints. However, formal verification tools like Reluplex or Neurify face a significant "complexity wall." As models grow in depth and width to achieve higher accuracy, the computational cost of verifying their properties grows exponentially, often resulting in timeouts or "Unknown" results.

This paper introduces R4V (Refactoring for Verification), a framework designed to bridge the gap between high-performance DNNs and state-of-the-art verification tools by simplifying model architectures while preserving their functional accuracy.

The R4V Framework

The R4V approach consists of a two-phase pipeline that transforms a complex "Teacher" network into a more verifiable "Student" network.

The R4V workflow: Architectural transformation followed by weight distillation to produce a verifiable network.

1. Architectural Transformation

In the first phase, the user defines specific operations to simplify the original network's structure. These transformations include:

  • Layer Dropping: Removing specific layers to reduce the overall depth of the model.
  • Layer Scaling: Reducing the number of neurons or filters within a layer to decrease the branching factor for solvers.
  • Linearization: Removing complex architectural features like residual (skip) connections that many formal verifiers cannot currently process.

2. Weight Distillation

Simply removing layers or neurons typically degrades a model's performance. To counteract this, R4V employs Knowledge Distillation. The simplified student network is trained to mimic the output of the original teacher network. This process allows the smaller, refactored model to retain much of the original's predictive power while being significantly easier for formal tools to analyze.

A core contribution of this work is the conceptualization of the "complexity sweet spot." There is an inherent tension between a model's error rate and its verification time. High-bias models (too simple) have high error, while high-variance models (too complex) become impossible to verify within a reasonable timeframe ($t_{max}$).

The complexity sweet spot represents the ideal balance where a model is accurate enough for the task but simple enough for formal verification.

R4V serves as a tool for developers to navigate this space, allowing them to systematically search for a model configuration that stays below both the maximum allowable error ($e_{max}$) and the verification time limit.

Key Results and Case Studies

The authors evaluated R4V on two substantial models: DAVE-2 (autonomous steering) and DroNet (UAV navigation). Using verifiers such as ReLuplex, ERAN, Neurify, and Planet, the study demonstrated several breakthroughs:

  • Enabling New Verifiers: R4V refactored the convolutional DAVE-2 model into a fully-connected architecture, allowing the ReLuplex verifier—which previously could not handle the model—to successfully verify 10 out of 10 safety properties.
  • Significant Performance Gains: For the DAVE-2 model, refactoring achieved an 8x speedup in verification time when using the Neurify tool.
  • Resolving "Unknowns": On the original DAVE-2, Neurify often timed out after 20,000 seconds, returning an "Unknown" status. A refactored version allowed all properties to be verified in under 3 hours each, maintaining a Mean Squared Error (MSE) below 0.01.
  • Automated Search: The authors showed that a systematic binary search through the "layer-dropping" space can efficiently identify the optimal model that meets both safety and performance requirements.

Conclusion

R4V demonstrates that verifiability should be treated as a first-class requirement in the DNN development lifecycle. By shifting the focus from general model compression to verification-specific refactoring, the framework enables the formal analysis of modern, high-performing models that were previously beyond the reach of existing tools. Future work may involve automating the search for optimal transformations using Neural Architecture Search (NAS) techniques specifically tuned for verifiability.

Summary updated

BibTeX
@misc{shriver2019refactoring,
  author = {David Shriver and Dong Xu and Sebastian G. Elbaum and Matthew B. Dwyer},
  title = {{Refactoring Neural Networks for Verification}},
  year = {2019},
  eprint = {1908.08026},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1908.08026},
}
Figure