Portfolio solver for verifying Binarized Neural Networks

Gergely Kovásznai, Krisztián Gajdár, Nina Narodytska˜Az 2021

Abstract

Although deep learning is a very successful AI technology, many concerns have been raised about the extent to which the decision-making process of deep neural networks can be trusted. Verifying properties of neural networks, such as adversarial robustness and network equivalence, sheds light on the trustworthiness of such systems. We focus on an important family of deep neural networks, the Binarized Neural Networks (BNNs), which are useful in resource-constrained environments like embedded devices. We introduce a portfolio solver capable of encoding BNN properties for SAT, SMT, and MIP solvers and running them in parallel. This paper proposes corresponding encodings for different types of BNN layers and properties into SAT, SMT, cardinality constraints, and pseudo-Boolean constraints. Our experimental results demonstrate that our solver can verify the adversarial robustness of medium-sized BNNs in reasonable time and appears to scale for larger BNNs. We also report promising results on network equivalence experiments.

Introduction

Deep neural networks (DNNs) have revolutionized fields from computer vision to natural language processing. However, their "black box" nature poses significant risks in safety-critical applications. Formal verification offers a path to building trust by mathematically proving that a network adheres to specific properties, such as remaining robust against adversarial perturbations.

This research specifically targets Binarized Neural Networks (BNNs). In BNNs, weights and activations are restricted to binary values (typically -1 and +1), significantly reducing memory footprint and computational requirements. While ideal for embedded systems, the discrete nature of BNNs makes their formal verification an NP-complete problem. Traditional verification methods often rely on a single solver type, which may struggle with the diverse logical landscapes presented by different network architectures.

Methodology: The Portfolio Architecture

To overcome the limitations of single-algorithm verification, we developed a portfolio solver implemented in Python. The core philosophy is to leverage the unique strengths of different mathematical solvers by running them in parallel.

Architecture of the Binarized Neural Networks (BNNs) targeted for verification.

As illustrated in Figure 1, the BNNs under study consist of sequential blocks. Each block typically contains a Linear (LIN) layer, followed by Batch Normalization (BN) and a Binarization (BIN) activation function. The final output block utilizes a Linear layer followed by an ARGMAX function to determine the classification. Our tool translates these specific layer structures into multiple "languages" or encodings:

  1. SAT (Boolean Satisfiability): Translates the network into pure logic gates and cardinality constraints.
  2. SMT (Satisfiability Modulo Theories): Combines logic with integer arithmetic or bit-vector theories.
  3. MIP (Mixed-Integer Programming): Formulates the verification task as a set of linear constraints for optimization solvers.

Using Python’s multiprocessing capabilities, the tool launches several solvers (such as MiniCARD for SAT, Z3 for SMT, and Gurobi for MIP) simultaneously. The first solver to find a proof or a counter-example "wins," allowing the system to bypass the performance bottlenecks of any single solver.

Experimental Setup and Datasets

We evaluated the portfolio solver using the MNIST dataset of handwritten digits. We trained two primary architectures for testing:

  • 4-block BNN: Achieved 93% accuracy.
  • 5-block BNN: Achieved 94% accuracy.

Verification was performed on 200 correctly classified images from the test set. We focused on two primary properties: Adversarial Robustness, ensuring no perturbation within a limit ($\epsilon$) changes the output, and Network Equivalence, proving two different BNNs produce identical outputs for all possible inputs.

Key Results and Insights

Solver Diversity and Performance

The experiments confirmed that no single solver is universally superior. Some instances that caused SAT solvers to time out were solved instantly by SMT, and vice versa. The combination of MiniCARD (a SAT solver handling cardinality constraints) and Z3 (a versatile SMT solver) proved to be the most effective "power couple" in the portfolio.

Efficiency in Robustness Verification

For the 4-block BNN, the portfolio solver achieved a high success rate, solving 195 to 200 out of 200 robustness instances. Notably, the solver is remarkably fast: 85–95% of instances were verified in under 30 seconds. Interestingly, as the perturbation limit ($\epsilon$) increased, the average runtime decreased (e.g., from 26.8s at $\epsilon=1$ to 8.7s at $\epsilon=5$). This is likely because a larger search space allows solvers to find counter-examples (adversarial attacks) more rapidly.

Network Equivalence

While more computationally demanding than robustness checking, the tool successfully identified differences between networks where only a few weights were modified. This demonstrates the tool's utility in verifying model compression or optimization processes where maintaining exact functional behavior is critical.

Conclusion and Future Work

The portfolio approach demonstrates significant scaling potential, moving effectively from 4-block to 5-block networks. Future work will focus on expanding the benchmark to more complex datasets beyond MNIST and integrating additional solvers like Google’s OR-Tools. We also aim to refine bit-vector (QF_BV) logic encodings in SMT solvers to further enhance verification speed for deeper, real-world BNN architectures.

Summary updated

Abstract

Although deep learning is a very successful AI technology, many concerns have been raised about to what extent the decisions making process of deep neural networks can be trusted. Verifying of properties of neural networks such as adversarial robustness and network equivalence sheds light on the trustiness of such systems. We focus on an important family of deep neural networks, the Binarized Neural Networks (BNNs) that are useful in resourceconstrained environments, like embedded devices. We introduce our portfolio solver that is able to encode BNN properties for SAT, SMT, and MIP solvers and run them in parallel, in a portfolio setting. In the paper we propose all the corresponding encodings of different types of BNN layers as well as BNN properties into SAT, SMT, cardinality constrains, and pseudo-Boolean constraints. Our experimental results demonstrate that our solver is capable of verifying adversarial robustness of medium-sized BNNs in reasonable time and seems to scale for larger BNNs. We also report on experiments on network equivalence with promising results.
BibTeX
@inproceedings{kovasznai2021portfolio,
  author = {Gergely Kovásznai and Krisztián Gajdár and Nina Narodytska},
  title = {{Portfolio solver for verifying Binarized Neural Networks}},
  booktitle = {˜Az},
  year = {2021},
  doi = {10.33039/ami.2021.03.007},
}
Figure