Skip to main content

Package for the training, pruning and verification of neural networks.

Project description

pyNeVer

Neural networks Verifier (NeVer 2) is a tool for the training, pruning and verification of neural networks. At present it supports sequential fully connected neural networks with ReLU and Sigmoid activation functions. pyNeVer is the corresponding python package providing all the main capabilities of the NeVer 2 tool and can be easily installed using pip. The PyPI project page can be found at https://pypi.org/project/pyNeVer/ whereas the github repository can be found at https://github.com/NeVerTools/pyNeVer.

REQUIREMENTS AND INSTALLATION

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

  • numpy
  • ortools
  • onnx
  • torch
  • torchvision
  • tensorflow *
  • pysmt

All the above packages are available via pip. * Notice that for ARM-based Mac OS the correct TensorFlow package is tensorflow-macos along with the GPU plug-in tensorflow-metal.

To install pyNeVer, run the command:

pip install pynever

To run some examples, further packages may be required. If an example requires a specific package, it will be detailed in the example directory.

DOCUMENTATION

The documentation related to the pyNeVer package can be found in the directory docs/pynever/ as html files.

SUPPORTED INPUTS

At present the pyNeVer package supports only the abstraction and verification of fully connected neural networks with ReLU and Sigmoid activation functions. The training, pruning and conversion supports also batch normalization layers. A network with batchnorm layers following fully connected layers can be converted to a "pure" fully connected neural networks using the capabilities provided in the utilities.py module.
The conversion.py 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. Examples of the python specification of the properties can be found in all the scripts in the directory examples/submissions/ATVA2021/.

EXAMPLES

NB: All the scripts should be executed INSIDE the related directory!

  • The directory examples/ contains some examples of application of the pyNeVer package. In particular the jupyter notebook shows a graphical example of the application of the abstraction module for the reachability of a small network with bi-dimensional input and outputs.

  • The pruning_example.py script show how to train and prune some small fully connected neural networks with relu activation function. It also show how it is possible to combine batch norm layer and fully connected layers to make the networks compliant with the requirements of the verification and abstraction modules.

  • The directory examples/submissions/ATVA2021 contains the experimental setup used for the experimental evaluation in our ATVA2021 paper. The experiments can be easily replicated by executing the python scripts acas_experiment.py from within the ATVA2021/ directory. The log files will be generated and will be saved in the logs/ directory.

  • The directory IEEEAccess2023 contains the experimental setup used for the experimental evaluation in our IEEEAccess2023 paper. To execute the experiments the additional package gym-pybullet-drones, with all its dependencies is needed. The script replicating the verification experiment on our benchmark is model_verification.py and the related results can be found in the logs folder. The other scripts are utilities scripts to generate the benchmarks and to convert the networks of interest in the standard ONNX format.

CONTRIBUTORS

The main contributors of pyNeVer are Dario Guidotti and Armando Tacchella, further contributions are provided by Stefano Demarchi.

Students contributions:

  • Alessandro Drago - TensorFlow conversion

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-0.0.2a6.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

pyNeVer-0.0.2a6-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file pyNeVer-0.0.2a6.tar.gz.

File metadata

  • Download URL: pyNeVer-0.0.2a6.tar.gz
  • Upload date:
  • Size: 55.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pyNeVer-0.0.2a6.tar.gz
Algorithm Hash digest
SHA256 fb0026d3913894eff2d3a49753f86c087f91bcfd8fd9e45e5fc8929feaad6407
MD5 9da384c69a3fa11b479bdecb4348585f
BLAKE2b-256 df14c823b68996a035d5ff63fae1bdadb1014a0b4ff18c1b705e023e601bb55b

See more details on using hashes here.

File details

Details for the file pyNeVer-0.0.2a6-py3-none-any.whl.

File metadata

  • Download URL: pyNeVer-0.0.2a6-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pyNeVer-0.0.2a6-py3-none-any.whl
Algorithm Hash digest
SHA256 66fab7b49e8d0057cc73d90b967adcc88ff9f88a06b593f178d8def836c785f9
MD5 c391d14b773b38fbf6a10a7eeb5f877e
BLAKE2b-256 ef63c93ddd02f8ef5da790ead60add59e4ef30ada40ffa410df35a59af3c4f63

See more details on using hashes here.

Supported by

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