tool for certifying local robustness in deep networks
Project description
fast-geometric-projections
Tool for certifying local robustness in deep networks.
This tool implements the algorithm described in the work, Fast Geometric Projections for Local Robustness Certification, appearing in ICLR 2021, and is maintained by the authors, Aymeric Fromherz, Klas Leino, Matt Fredrikson, Bryan Parno, and Corina Păsăreanu.
If you use this tool, please use the following citation:
@INPROCEEDINGS{fromherz20projections,
title={Fast Geometric Projections for Local Robustness Certification},
author={Aymeric Fromherz and Klas Leino and Matt Fredrikson and Bryan Parno and Corina Păsăreanu},
booktitle={International Conference on Learning Representations (ICLR)},
year={2021},
}
Installation
Simply install via pip:
pip install fgp-cert
Alternatively, you can install from the source repository:
-
Clone the repository and change into its root directory.
-
Install from source via
pip install -e .
Checking Robustness
The main routine for checking robustness is the check function in fgp.certification. This takes the following arguments:
network: the neural network to be certified. Must be an instance ofCheckableModel(found in thefgp.checkable_modelsmodule).x: anumpy.Arraycontaining the instance to check robustness for.epsilon: the value of ε to check robustness for.timeout: (optional) the number of seconds to compute for before returning aTIMED_OUTresult. IfNone, the computation will continue until the search has completed. NOTE: the time-out functionality will not work on Windows, since it uses signals. We recommend running on a unix machine.lowerbound: (default False) boolean flag specifying that we would like to use the certified lower bound algorithm (presented in Section 2.3) rather than the standard FGP algorithm (presented in Section 2.1).keepgoing: (default False) when True, uses the heuristic given in Section 2.2 for decreasing the number ofUNKNOWNresults by continuing to search the queue when a possible false-positive is found. This heuristic can only be used whenlowerboundisFalse.batch_size: (default 1) batch size for processing the queue. Setting to 10-100 for medium to large examples significantly speeds up the FGP algorithm; however, for very large networks, this becomes very memory-intensive. The batch size must be 1 whenlowerboundisTrue.return_num_visited: (optional) if set toTrue, the algorithm will return a tuple containing the robustness result followed by the number of regions visited. Otherwise it will return the robustness result only.recap: (default False) if set toTrue, the algorithm will print out a few statistics as it computes.debug_steps: (default False) if set toTrue, the algorithm will print out more detailed statistics as it computes.debug_print_rate: (default 1) ifdebug_stepsis True, detailed information will be printed everydebug_print_rateiterations of the algorithm.
The CheckableModel Wrapper
The functionality required to compute projections to internal and decision boundaries is contained in the wrapper class, CheckableModel.
The check routine only functions on instances of CheckableModel.
The constructor for Checkable model takes an input shape, a list of internal layer widths, and a number of output classes.
For example, to create a dense network on the MNIST dataset with three hidden layers of 20 neurons each, the following would be used:
from fgp import CheckableModel
network = CheckableModel((784,), [20, 20, 20], 10)
Before running the check function on a model, the graph for computing boundaries and projections (for the desired norm) must be compiled.
This can be done using the following:
# Defaults to the L2 norm.
network.compile_backprop()
# The norm can also be specified:
network.compile_backprop('l2')
network.compile_backprop('linf')
Examples
An example script demonstrating the use of check can be found in examples/scripts/evaluation_script.py.
This script can be called from the command line; an example usage can be found in examples/scripts/example.sh.
A number of pre-trained weights for the models used in the paper are provided in examples/models/.
Main Contributers
- Klas Leino
- Aymeric Fromherz
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fgp-cert-0.0.3.tar.gz.
File metadata
- Download URL: fgp-cert-0.0.3.tar.gz
- Upload date:
- Size: 3.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b33c2d10ae7a5d869b458e5bb8783f07511d5f05fe541d3b6a5ca92abc66179f
|
|
| MD5 |
18c17feec40b665fed0f5e3ec42a74e3
|
|
| BLAKE2b-256 |
35834005175a4fbc2f5e608842ff07d6c2a50d36e147dff2786819314d000e49
|
File details
Details for the file fgp_cert-0.0.3-py3-none-any.whl.
File metadata
- Download URL: fgp_cert-0.0.3-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d24ba05556d0d2572f6445917dbe6e382287c9e6761d8cbacf63c54a168b2edd
|
|
| MD5 |
ad3f432046e82ee02249979a7fe24513
|
|
| BLAKE2b-256 |
f8acf6aeefaccd6e1a0f923d85347cf5c3414d864c1cf133205cde4c1f6bed1a
|