Need help with eran?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

eth-sri
155 Stars 54 Forks Apache License 2.0 343 Commits 6 Opened issues

Description

ETH Robustness Analyzer for Deep Neural Networks

Services available

!
?

Need anything else?

Contributors list

ERAN portfolio_view

High Level

ETH Robustness Analyzer for Neural Networks (ERAN) is a state-of-the-art sound, precise, scalable, and extensible analyzer based on abstract interpretation for the complete and incomplete verification of MNIST, CIFAR10, and ACAS Xu based networks. ERAN produces state-of-the-art precision and performance for both complete and incomplete verification and can be tuned to provide best precision and scalability (see recommended configuration settings at the bottom). ERAN is developed at the SRI Lab, Department of Computer Science, ETH Zurich as part of the Safe AI project. The goal of ERAN is to automatically verify safety properties of neural networks with feedforward, convolutional, and residual layers against input perturbations (e.g., L∞-norm attacks, geometric transformations, vector field deformations, etc).

ERAN supports fully-connected, convolutional, and residual networks with ReLU, Sigmoid, Tanh, and Maxpool activations and is sound under floating point arithmetic. It employs custom abstract domains which are specifically designed for the setting of neural networks and which aim to balance scalability and precision. Specifically, ERAN supports the following four analysis:

  • DeepZ [NIPS'18]: contains specialized abstract Zonotope transformers for handling ReLU, Sigmoid and Tanh activation functions.

  • DeepPoly [POPL'19]: based on a domain that combines floating point Polyhedra with Intervals.

  • RefineZono [ICLR'19]: combines DeepZ analysis with MILP and LP solvers for more precision.

  • RefinePoly [NeurIPS'19]: combines DeepPoly analysis with MILP and k-ReLU framework for state-of-the-art precision while maintaining scalability.

All analysis are implemented using the ELINA library for numerical abstractions. More details can be found in the publications below.

ERAN vs AI2

Note that ERAN subsumes the first abstract interpretation based analyzer AI2, so if you aim to compare, please use ERAN as a baseline.

USER MANUAL

For a detailed desciption of the options provided and the implentation of ERAN, you can download the user manual.

Requirements

GNU C compiler, ELINA, Gurobi's Python interface,

python3.6 or higher, tensorflow 1.11 or higher, numpy.

Installation

Clone the ERAN repository via git as follows:

git clone https://github.com/eth-sri/ERAN.git
cd ERAN

The dependencies for ERAN can be installed step by step as follows (sudo rights might be required):

Install m4:

wget ftp://ftp.gnu.org/gnu/m4/m4-1.4.1.tar.gz
tar -xvzf m4-1.4.1.tar.gz
cd m4-1.4.1
./configure
make
make install
cp src/m4 /usr/bin
cd ..
rm m4-1.4.1.tar.gz

Install gmp:

wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
tar -xvf gmp-6.1.2.tar.xz
cd gmp-6.1.2
./configure --enable-cxx
make
make install
cd ..
rm gmp-6.1.2.tar.xz

Install mpfr:

wget https://files.sri.inf.ethz.ch/eran/mpfr/mpfr-4.1.0.tar.xz
tar -xvf mpfr-4.1.0.tar.xz
cd mpfr-4.1.0
./configure
make
make install
cd ..
rm mpfr-4.1.0.tar.xz

Install cddlib: ``` git clone https://github.com/cddlib/cddlib.git cd cddlib ./configure make make install cd ..

Install Gurobi:

wget https://packages.gurobi.com/9.0/gurobi9.0.0linux64.tar.gz tar -xvf gurobi9.0.0linux64.tar.gz cd gurobi900/linux64/src/build sed -ie 's/^C++FLAGS =.*$/& -fPIC/' Makefile make cp libgurobi_c++.a ../../lib/ cd ../../ cp lib/libgurobi90.so /usr/lib python3 setup.py install cd ../../

Update environment variables:

export GUROBIHOME="Currentdirectory/gurobi900/linux64" export PATH="${PATH}:${GUROBIHOME}/bin" export CPATH="${CPATH}:${GUROBIHOME}/include" export LDLIBRARYPATH=$LDLIBRARYPATH:/usr/local/lib:${GUROBI_HOME}/lib

Install ELINA:

git clone https://github.com/eth-sri/ELINA.git cd ELINA ./configure -use-deeppoly -use-gurobi -use-fconv make make install cd .. ```

Install DeepG (note that with an already existing version of ERAN you have to start at step Install Gurobi): ``` git clone https://github.com/eth-sri/deepg.git cd deepg/code mkdir build make shared_object cp ./build/libgeometric.so /usr/lib cd ../..

We also provide scripts that will install ELINA and all the necessary dependencies. One can run it as follows:

sudo ./install.sh source gurobisetuppath.sh

Note that to run ERAN with Gurobi one needs to obtain an academic license for gurobi from https://user.gurobi.com/download/licenses/free-academic.

To install the remaining python dependencies (numpy and tensorflow), type:

pip3 install -r requirements.txt ```

ERAN may not be compatible with older versions of tensorflow (we have tested ERAN with versions >= 1.11.0), so if you have an older version and want to keep it, then we recommend using the python virtual environment for installing tensorflow.

Usage

cd tf_verify

python3 . --netname --epsilon --domain --dataset --zonotope [optional] --complete --timeout_complete --timeout_lp --timeout_milp --use_area_heuristic --mean --std --use_milp --use_2relu --use_3relu --dyn_krelu --numproc

  • : specifies bound for the L∞-norm based perturbation (default is 0). This parameter is not required for testing ACAS Xu networks.
  • : The Zonotope specification file can be comma or whitespace separated file where the first two integers can specify the number of input dimensions D and the number of error terms per dimension N. The following D*N doubles specify the coefficient of error terms. For every dimension i, the error terms are numbered from 0 to N-1 where the 0-th error term is the central error term. See an example here [https://github.com/eth-sri/eran/files/3653882/zonotope_example.txt]. This option only works with the "deepzono" or "refinezono" domain.
  • : specifies whether to use area heuristic for the ReLU approximation in DeepPoly (default is true).
  • : specifies mean used to normalize the data. If the data has multiple channels the mean for every channel has to be provided (e.g. for cifar10 --mean 0.485, 0.456, 0.406) (default is 0 for non-geometric mnist and 0.5 0.5 0.5 otherwise)
  • : specifies standard deviation used to normalize the data. If the data has multiple channels the standard deviaton for every channel has to be provided (e.g. for cifar10 --std 0.2 0.3 0.2) (default is 1 1 1)
  • : specifies whether to use MILP (default is true).
  • : specifies the size of "k" for the kReLU framework (default is 70).
  • : specifies how many processes to use for MILP, LP and k-ReLU (default is the number of processors in your machine).
  • : specifies whether to do geometric analysis (default is false).
  • : specifies the geometric configuration file location.
  • : specifies the geometric data location.
  • : specifies the number of transformation parameters (default is 0)
  • : specifies whether to verify attack images (default is false).
  • : the property number for the ACASXu networks
  • Refinezono and RefinePoly refines the analysis results from the DeepZ and DeepPoly domain respectively using the approach in our ICLR'19 paper. The optional parameters timeoutlp and timeoutmilp (default is 1 sec for both) specify the timeouts for the LP and MILP forumlations of the network respectively.

  • Since Refinezono and RefinePoly uses timeout for the gurobi solver, the results will vary depending on the processor speeds.

  • Setting the parameter "complete" (default is False) to True will enable MILP based complete verification using the bounds provided by the specified domain.

  • When ERAN fails to prove the robustness of a given network in a specified region, it searches for an adversarial example and prints an adversarial image within the specified adversarial region along with the misclassified label and the correct label. ERAN does so for both complete and incomplete verification.

Example

Loo Specification ``` python3 . --netname ../nets/pytorch/mnist/convBig_DiffAI.pyt --epsilon 0.1 --domain deepzono --dataset mnist ```

will evaluate the local robustness of the MNIST convolutional network (upto 35K neurons) with ReLU activation trained using DiffAI on the 100 MNIST test images. In the above setting, epsilon=0.1 and the domain used by our analyzer is the deepzono domain. Our analyzer will print the following:

  • 'Verified safe' for an image when it can prove the robustness of the network

  • 'Verified unsafe' for an image for which it can provide a concrete adversarial example

  • 'Failed' when it cannot.

  • It will also print an error message when the network misclassifies an image.

  • the timing in seconds.

  • The ratio of images on which the network is robust versus the number of images on which it classifies correctly.

Zonotope Specification

python3 . --netname ../nets/pytorch/mnist/convBig__DiffAI.pyt --zonotope some_path/zonotope_example.txt --domain deepzono 

will check if the Zonotope specification specified in "zonotope_example" holds for the network and will output "Verified safe", "Verified unsafe" or "Failed" along with the timing.

Similarly, for the ACAS Xu networks, ERAN will output whether the property has been verified along with the timing.

ACASXu Specification

python3 . --netname ../data/acasxu/nets/ACASXU_run2a_3_3_batch_2000.onnx --dataset acasxu --domain deepzono  --specnumber 9
will run DeepZ for analyzing property 9 of ACASXu benchmarks. The ACASXU networks are in data/acasxu/nets directory and the one chosen for a given property is defined in the Reluplex paper.

Geometric analysis

python3 . --netname ../nets/pytorch/mnist/convBig__DiffAI.pyt --geometric --geometric_config ../deepg/code/examples/example1/config.txt --num_params 1 --dataset mnist

will on the fly generate geometric perturbed images and evaluate the network against them. For more information on the geometric configuration file please see Format of the configuration file in DeepG.

python3 . --netname ../nets/pytorch/mnist/convBig__DiffAI.pyt --geometric --data_dir ../deepg/code/examples/example1/ --num_params 1 --dataset mnist --attack

will evaluate the generated geometric perturbed images in the given data_dir and also evaluate generated attack images.

Recommended Configuration for Scalable Complete Verification

Use the "deeppoly" or "deepzono" domain with "--complete True" option

Recommended Configuration for More Precise but relatively expensive Incomplete Verification

Use the "refinepoly" domain with "--usemilp True", "--sparsen 12", "--refineneurons", "timeoutmilp 10", and "timeout_lp 10" options

Recommended Configuration for Faster but relatively imprecise Incomplete Verification

Use the "deeppoly" domain

Certification of Vector Field Deformations

High Level

Vector field deformations, which displace pixels instead of directly manipulating pixel values, can be intuitively parametrized by their displacement magnitude delta, i.e., how far every pixel can move, and their smoothness gamma, i.e., how much neighboring displacement vectors can differ from each other (more details can be found in Section 3 of our paper). ERAN can certify both non-smooth vector fields:

python3 . --netname ../nets/pytorch/mnist/convBig__DiffAI.pyt --dataset mnist --domain deeppoly --spatial --t-norm inf --delta 0.3
and smooth vector fields:
python3 . --netname ../nets/pytorch/mnist/convBig__DiffAI.pyt --dataset mnist --domain deeppoly --spatial --t-norm inf --delta 0.3 --gamma 0.1
Certification of vector field deformations is compatible with the "deeppoly" and "refinepoly" domains, and can be made more precise with the kReLU framework (e.g., "--usemilp True", "--sparsen 15", "--refineneurons", "timeoutmilp 10", and "timeout_lp 10") or complete certification ("--complete True").

Publications

Anian Ruoss, Maximilian Baader, Mislav Balunovic, Martin Vechev

arXiv 2020.

Mislav Balunovic, Maximilian Baader, Gagandeep Singh, Timon Gehr, Martin Vechev

NeurIPS 2019.

Neural Networks and Datasets

We provide a number of pretrained MNIST and CIAFR10 defended and undefended feedforward and convolutional neural networks with ReLU, Sigmoid and Tanh activations trained with the PyTorch and TensorFlow frameworks. The adversarial training to obtain the defended networks is performed using PGD and DiffAI.

| Dataset | Model | Type | #units | #layers| Activation | Training Defense| Download | | :-------- | :-------- | :-------- | :-------------| :-------------| :------------ | :------------- | :---------------:| | MNIST | 3x50 | fully connected | 110 | 3 | ReLU | None | :arrow_down:| | | 3x100 | fully connected | 210 | 3 | ReLU | None | :arrow_down:| | | 5x100 | fully connected | 510 | 5 | ReLU | DiffAI | :arrow_down:| | | 6x100 | fully connected | 510 | 6 | ReLU | None | :arrow_down:| | | 9x100 | fully connected | 810 | 9 | ReLU | None | :arrow_down:| | | 6x200 | fully connected | 1,010 | 6 | ReLU | None | :arrow_down:| | | 9x200 | fully connected | 1,610 | 9 | ReLU | None | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | ReLU | None | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | ReLU | PGD ε=0.1 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | ReLU | PGD ε=0.3 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Sigmoid | None | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Sigmoid | PGD ε=0.1 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Sigmoid | PGD ε=0.3 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Tanh | None | :arrow_down:| | | 6x500 | fully connected| 3,000 | 6 | Tanh | PGD ε=0.1 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Tanh | PGD ε=0.3 | :arrow_down:| | | 4x1024 | fully connected | 3,072 | 4 | ReLU | None | :arrow_down:| | | ConvSmall | convolutional | 3,604 | 3 | ReLU | None | :arrow_down:| | | ConvSmall | convolutional | 3,604 | 3 | ReLU | PGD | :arrow_down: | | | ConvSmall | convolutional | 3,604 | 3 | ReLU | DiffAI | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | ReLU | None | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | ReLU | PGD ε=0.1 | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | ReLU | PGD ε=0.3 | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | Sigmoid | None | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | Sigmoid | PGD ε=0.1 | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | Sigmoid | PGD ε=0.3 | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | Tanh | None | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | Tanh | PGD ε=0.1 | :arrow_down: | | | ConvMed | convolutional | 5,704 | 3 | Tanh | PGD ε=0.3 | :arrow_down: | | | ConvMaxpool | convolutional | 13,798 | 9 | ReLU | None | :arrow_down:| | | ConvBig | convolutional | 48,064 | 6 | ReLU | DiffAI | :arrow_down: | | | ConvSuper | convolutional | 88,544 | 6 | ReLU | DiffAI | :arrow_down: | | | Skip | Residual | 71,650 | 9 | ReLU | DiffAI | :arrow_down: | | CIFAR10 | 4x100 | fully connected | 410 | 4 | ReLU | None | :arrow_down: | | | 6x100 | fully connected | 610 | 6 | ReLU | None | :arrow_down: | | | 9x200 | fully connected | 1,810 | 9 | ReLU | None | :arrow_down: | | | 6x500 | fully connected | 3,000 | 6 | ReLU | None | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | ReLU | PGD ε=0.0078 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | ReLU | PGD ε=0.0313 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Sigmoid | None | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Sigmoid | PGD ε=0.0078 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Sigmoid | PGD ε=0.0313 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Tanh | None | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Tanh | PGD ε=0.0078 | :arrow_down:| | | 6x500 | fully connected | 3,000 | 6 | Tanh | PGD ε=0.0313 | :arrow_down:| | | 7x1024 | fully connected | 6,144 | 7 | ReLU | None | :arrow_down: | | | ConvSmall | convolutional | 4,852 | 3 | ReLU | None | :arrow_down:| | | ConvSmall | convolutional | 4,852 | 3 | ReLU | PGD | :arrow_down:| | | ConvSmall | convolutional | 4,852 | 3 | ReLU | DiffAI | :arrow_down:| | | ConvMed | convolutional | 7,144 | 3 | ReLU | None | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | ReLU | PGD ε=0.0078 | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | ReLU | PGD ε=0.0313 | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | Sigmoid | None | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | Sigmoid | PGD ε=0.0078 | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | Sigmoid | PGD ε=0.0313 | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | Tanh | None | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | Tanh | PGD ε=0.0078 | :arrow_down: | | | ConvMed | convolutional | 7,144 | 3 | Tanh | PGD ε=0.0313 | :arrow_down: |
| | ConvMaxpool | convolutional | 53,938 | 9 | ReLU | None | :arrow_down:| | | ConvBig | convolutional | 62,464 | 6 | ReLU | DiffAI | :arrow_down: | | | ResNet18 | Residual | 558K | 18 | ReLU | DiffAI | :arrow_down: |

We provide the first 100 images from the testset of both MNIST and CIFAR10 datasets in the 'data' folder. Our analyzer first verifies whether the neural network classifies an image correctly before performing robustness analysis. In the same folder, we also provide ACAS Xu networks and property specifications.

Experimental Results

We ran our experiments for the feedforward networks on a 3.3 GHz 10 core Intel i9-7900X Skylake CPU with a main memory of 64 GB whereas our experiments for the convolutional networks were run on a 2.6 GHz 14 core Intel Xeon CPU E5-2690 with 512 GB of main memory. We first compare the precision and performance of DeepZ and DeepPoly vs Fast-Lin on the MNIST 6x100 network in single threaded mode. It can be seen that DeepZ has the same precision as Fast-Lin whereas DeepPoly is more precise while also being faster.

High Level

In the following, we compare the precision and performance of DeepZ and DeepPoly on a subset of the neural networks listed above in multi-threaded mode. In can be seen that DeepPoly is overall more precise than DeepZ but it is slower than DeepZ on the convolutional networks.

High Level

High Level

High Level

High Level

The table below compares the performance and precision of DeepZ and DeepPoly on our large networks trained with DiffAI.

Dataset Model ε % Verified Robustness % Average Runtime (s)
DeepZ DeepPoly DeepZ DeepPoly
MNIST ConvBig 0.1 97 97 5 50
ConvBig 0.2 79 78 7 61
ConvBig 0.3 37 43 17 88
ConvSuper 0.1 97 97 133 400
Skip 0.1 95 N/A 29 N/A
CIFAR10 ConvBig 0.006 50 52 39 322
ConvBig 0.008 33 40 46 331

The table below compares the timings of complete verification with ERAN for all ACASXu benchmarks.

Property Networks % Average Runtime (s)
1 all 45 15.5
2 all 45 11.4
3 all 45 1.9
4 all 45 1.1
5 1_1 26
6 1_1 10
7 1_9 83
8 2_9 111
9 3_3 9
10 4_5 2.1

More experimental results can be found in our papers.

Contributors

License and Copyright

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.