Skip to main content

Deep Neural Network Verification

A framework for verification and analysis of deep neural networks. You can read an overview of DNNV in our CAV 2021 paper DNNV: A Framework for Deep Neural Network Verification, or watch our presentation on YouTube.

Getting Started

For detailed instructions on installing and using DNNV, see our documentation.

Installation

DNNV requires python >=3.7,<3.10, and has been tested on linux. To install the latest stable version run:

$ pip install dnnv

or

$ pip install git+https://github.com/dlshriver/DNNV.git@main

We recommend installing DNNV into a python virtual environment.

Install any of the supported verifiers (Reluplex, planet, MIPVerify.jl, Neurify, ERAN, BaB, marabou, nnenum, verinet):

$ dnnv_manage install reluplex planet mipverify neurify eran bab marabou nnenum verinet

Several verifiers make use of the Gurobi 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 the Gurobi website.

After installing a verifier that requires Gurobi, the grbgetkey command can be found at .venv/opt/gurobi912/linux64/bin/grbgetkey.

Source Installation

First create and activate a python virtual environment.

$ python -m venv .venv
$ . .venv/bin/activate

Then run the following commands to clone DNNV and install it into the virtual environment:

$ git clone https://github.com/dlshriver/DNNV.git
$ cd DNNV
$ pip install .

Verifiers can then be installed using the dnnv_manage tool as described above.

Make sure that the project environment is activated when using dnnv or the dnnv_manage tools.

Docker Installation

We 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:

$ docker pull dlshriver/dnnv:latest
$ docker run --rm -it dlshriver/dnnv:latest
(.venv) dnnv@hostname:~$ dnnv -h

The latest version of the develop branch is available as dlshriver/dnnv:develop, and tagged releases are available as dlshriver/dnnv:vX.X.X where vX.X.X is 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:

$ docker build . -t dlshriver/dnnv
$ docker run --rm -it dlshriver/dnnv
(.venv) dnnv@hostname:~$ dnnv -h

Usage

Properties 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.

from dnnv.properties import *

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:

$ dnnv property.dnnp --network N network.onnx --eran

Additionally, if the property defines parameters, using the Parameter keyword, they can be specified on the command line using the option --prop.PARAMETER_NAME, where PARAMETER_NAME is the name of the parameter. For the property defined above, a value for epsilon can be provided with a command line option as follows:

$ dnnv property.dnnp --network N network.onnx --eran --prop.epsilon=2.0

To save any counter-example found by the verifier, use the option --save-violation /path/to/array.npy when 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 Problems

We have made several DNN verification benchmarks available in DNNP+ONNX format in dlshriver/dnnv-benchmarks. This repo includes the ACAS Xu benchmark, ready to run with DNNV!

Acknowledgements

This material is based in part upon work supported by the National Science Foundation under grant number 1900676 and 2019239.

Metadata

Release files for dnnv 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dnnv 0.6.0
File Size Uploaded Provenance
dnnv-0.6.0.tar.gz 11.3 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dnnv 0.6.0
File Interpreter ABI Platform
dnnv-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 MB

Release files / dnnv-0.6.0.tar.gz

Download URL dnnv-0.6.0.tar.gz
Size 11.3 MB
Tags Source
SHA-256 checksum
How to use checksums
be76b3e1a29a412b6bf030228173f63f200c512bb9df9268673393a96f9df1ad
BLAKE2b-256 checksum
How to use checksums
a836fcde4583a6a5a5563e6c85a494c189986e4c386d7ad9332e448ad13cf0e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release files / dnnv-0.6.0-py3-none-any.whl

Download URL dnnv-0.6.0-py3-none-any.whl
Size 163.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3d21db1664a1329c892e025638ed642120a53b48e8fd47f89e3147b578c79d3
BLAKE2b-256 checksum
How to use checksums
6be3c6740ef2d5aae6b48c9d0a964eaaf272e151a790902cf870aee664b9d451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Security for dnnv 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page