Skip to main content

API for the design, training and verification of neural networks.

Project description

pyNeVer

PyPI - Version PyPI - Python Version


Neural networks Verifier (NeVer 2) is a tool for the design, training and verification of neural networks. It supports feed-forward and residual neural networks with ReLU and activation functions. pyNeVer is the corresponding python package providing all the main capabilities of NeVer 2 and can be easily installed using pip.

Installation and setup

pyNeVer depends on several packages, which are all available via pip and should be installed automatically. The packages required for the correct execution are the following:

  • numpy
  • ortools
  • onnx
  • torch
  • torchvision
  • pysmt
  • multipledispatch

To install pyNeVer as an API, run the command:

pip install pynever

To run pyNeVer as a standalone tool you should clone this repository and create a conda environment

git clone https://github.com/nevertools/pyNeVer
cd pyNeVer

conda env create -f environment.yml
conda activate pynever

Command-line interface

To verify VNN-LIB specifications on ONNX models we provide two scripts: one for single instances and another one for multiple instances. To verify a single instance run

python never2_launcher.py [-o OUTPUT] [-t TIMEOUT] model.onnx property.vnnlib {sslp|ssbp}

For multiple instances collected in a CSV file run

python never2_batch.py [-o OUTPUT] [-t TIMEOUT] instances.csv {sslp|ssbp}
  • The -o option should be used to specify the output CSV file to save results, otherwise it will be generated in the same directory
  • The -t option specifies the timeout for each run
  • sslp and ssbp are the two algorithms employed by NeVer2:
    • SSLP (Star-set with Linear Programming) is our first algorithm based on star sets presented in this paper.
    • SSBP (Star-set with Bounds Propagation) enhances SSLP with an abstraction-refinement search and symbolic interval propagation. This is the algorithm used in VNNCOMP 2024.

API

In the notebooks directory there are four Jupyter Notebooks that illustrate how to use pyNever as an API to design, train and verify neural networks.

  • The first notebook covers the classes and methods to build networks
  • The second notebook covers the learning strategy to train and test a network
  • The third notebook explains how to build a safety specification to define a verification problem
  • The fourth notebook explains our verification algorithms and covers how to instantiate and execute verification

Supported layers

At present the pyNeVer package supports abstraction and verification of fully connected and convolutional neural networks with ReLU activation functions.

Training and conversion support all the layers supported by VNN-LIB.

The conversion package provides the capabilities for the conversion of PyTorch and ONNX networks: therefore this kind of networks can be loaded using the respective frameworks and then converted to the internal representation used by pyNeVer.

The properties for the verification and abstraction of the networks must be defined either in python code following the specification which can be found in the documentation, or via an SMT-LIB file compliant to the VNN-LIB standard.

Contributors

The main contributors of pyNeVer are Dario Guidotti and Stefano Demarchi, under the supervision of Professors Armando Tacchella and Luca Pulina.
A significant contribution for the participation in VNN-COMP 2024 was the help of Elena Botoeva.

Other contributors:

  • Andrea Gimelli - Bound propagation integration
  • Pedro Henrique Simão Achete - Command-line interface and convolutional linearization
  • Karim Pedemonte - Design and refactoring

To contribute to this project, start by looking at the CONTRIBUTING file!

Publications

If you use NeVer2 or pyNeVer in your work, please kindly cite our papers. Here you can find the list of BibTeX entries.

@article{demarchi2024never2,
	author = {Demarchi, S. and Guidotti, D. and Pulina, L. and Tacchella, A.},
	journal = {Soft Computing},
	number = {19},
	pages = {11647-11665},
	title = {{NeVer2}: learning and verification of neural networks},
	volume = {28},
	year = {2024}
}

@inproceedings{demarchi2024improving,
	author = {Demarchi, S. and Gimelli, A. and Tacchella, A.},
	booktitle = {{ECMS} International Conference on Modelling and Simulation},
	title = {Improving Abstract Propagation for Verification of Neural Networks},
	year = {2024}
}

@inproceedings{demarchi2022formal,
	author = {Demarchi, S. and Guidotti, D. and Pitto, A. and Tacchella, A.},
	booktitle = {{ECMS} International Conference on Modelling and Simulation},
	title = {Formal Verification of Neural Networks: {A} Case Study About Adaptive Cruise Control},
	year = {2022}
}

@inproceedings{guidotti2021pynever,
    author={Guidotti, D. and Pulina, L. and Tacchella, A.},
    booktitle={International Symposium on Automated Technology for Verification and Analysis},
    title={pynever: A framework for learning and verification of neural networks},
    year={2021},
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynever-1.2.6.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

pynever-1.2.6-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file pynever-1.2.6.tar.gz.

File metadata

  • Download URL: pynever-1.2.6.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pynever-1.2.6.tar.gz
Algorithm Hash digest
SHA256 0fc17f03c3b8c0e603577ac0bc847987928d757385bae4ec432bea063b7ca695
MD5 30f55b3317940f5845335f6d7a4797f3
BLAKE2b-256 aa09a1bc34e372ea0adc5c99b35ed8991d2cb98f5d2c99b2467c7308456e1d41

See more details on using hashes here.

File details

Details for the file pynever-1.2.6-py3-none-any.whl.

File metadata

  • Download URL: pynever-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for pynever-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b23b4a67ed84d11e4d23bc3ff2200df1e1ca31e7018ca339e79dd471d6e72f21
MD5 266d8436afa0024e310a8eb4d88a699f
BLAKE2b-256 72e5494107f19a8bb5fb88730d528701c3502e2e2caa7d8a217536f19f3b771a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page