Package: dnnv
Deep Neural Network VerificationA framework for verification and analysis of deep neural networks. You can read an overview of DNNV in our CAV 2021 paperDNNV: A Framework for Deep Neural Network Verification, or watch our presentation onYouTube.Getting StartedFor detailed instructions on installing and using DNNV, see ourdocumentation.InstallationDNNV requires python >=3.7,<3.10, and has been tested on linux. To install the latest stable version run:$pipinstalldnnvor$pipinstallgit+https://github.com/dlshriver/DNNV.git@mainWe recommend installing DNNV into apython virtual environment.Install any of the supported verifiers (Reluplex,planet,MIPVerify.jl,Neurify,ERAN,BaB,marabou,nnenum,verinet):$dnnv_manageinstallreluplexplanetmipverifyneurifyeranbabmarabounnenumverinetSeveral verifiers make use of theGurobi solver.This should be installed automatically, but requires a license to be manually activated and available on the host machine. Academic licenses can be obtained for free from theGurobi website.After installing a verifier that requires Gurobi, the grbgetkey command can be found at.venv/opt/gurobi912/linux64/bin/grbgetkey.Source InstallationFirst create and activate a python virtual environment.$python-mvenv.venv
$..venv/bin/activateThen run the following commands to clone DNNV and install it into the virtual environment:$gitclonehttps://github.com/dlshriver/DNNV.git
$cdDNNV
$pipinstall.Verifiers can then be installed using thednnv_managetool as described above.Make sure that the project environment is activatedwhen using dnnv or the dnnv_manage tools.Docker InstallationWe provide a docker image with DNNV and all non-Gurobi dependent verifiers. To obtain and use the latest pre-built image of the main branch, run:$dockerpulldlshriver/dnnv:latest
$dockerrun--rm-itdlshriver/dnnv:latest(.venv)dnnv@hostname:~$dnnv-hThe latest version of the develop branch is available asdlshriver/dnnv:develop, and tagged releases are available asdlshriver/dnnv:vX.X.XwherevX.X.Xis the desired version number.The docker image can also be built using the provided Dockerfile. The provided build file will install DNNV with all of the verifiers that do not require Gurobi. To build and run the docker image, run:$dockerbuild.-tdlshriver/dnnv
$dockerrun--rm-itdlshriver/dnnv(.venv)dnnv@hostname:~$dnnv-hUsageProperties are specified in our Python-embedded DSL,DNNP. A property specification can import python modules, and define variables. The only required component is the property expression, which must appear at the end of the file. An example of a local robustness property is shown below.fromdnnv.propertiesimport*N=Network("N")x=Image("path/to/image")epsilon=Parameter("epsilon",float,default=1.0)Forall(x_,Implies(((x-epsilon)<x_<(x+epsilon)),argmax(N(x_))==argmax(N(x))),),)To check whether property holds for some network using the ERAN verifier, run:$dnnvproperty.dnnp--networkNnetwork.onnx--eranAdditionally, if the property defines parameters, using theParameterkeyword, they can be specified on the command line using the option--prop.PARAMETER_NAME, wherePARAMETER_NAMEis the name of the parameter. For the property defined above, a value forepsiloncan be provided with a command line option as follows:$dnnvproperty.dnnp--networkNnetwork.onnx--eran--prop.epsilon=2.0To save any counter-example found by the verifier, use the option--save-violation /path/to/array.npywhen running DNNV. This will save any violation found as a numpy array at the path specified, which is useful for viewing counter-examples to properties and enables additional debugging and analysis later.Example ProblemsWe have made several DNN verification benchmarks available in DNNP+ONNX format indlshriver/dnnv-benchmarks.
This repo includes theACAS Xubenchmark, ready to run with DNNV!AcknowledgementsThis material is based in part upon work supported by the National Science Foundation under grant number 1900676 and 2019239.