stAdv: Spatially Transformed Adversarial Examples with TensorFlow
Deep neural networks have been shown to be vulnerable to adversarial examples: very small perturbations of the input having a dramatic impact on the predictions. In this package, we provide a TensorFlow implementation for a new type of adversarial attack based on local geometric transformations: Spatially Transformed Adversarial Examples (stAdv).
Our implementation follows the procedure from the original paper:
Spatially Transformed Adversarial ExamplesChaowei Xiao, Jun-Yan Zhu, Bo Li, Warren He, Mingyan Liu, Dawn Song
If you use this code, please cite the following paper for which this implementation was originally made:
Robustness of Rotation-Equivariant Networks to Adversarial PerturbationsBeranger Dumont, Simona Maggio, Pablo Montalvo
Installation
First, make sure you have installed TensorFlow (CPU or GPU version).
Then, to install the stadv package, simply run
$ pip install stadv
Usage
A typical use of this package is as follows:
Start with a trained network implemented in TensorFlow.
Insert the stadv.layers.flow_st layer in the graph immediately after the input layer. This is in order to perturb the input images according to local differentiable geometric perturbations parameterized with input flow tensors.
In the end of the graph, after computing the logits, insert the computation of an adversarial loss (to fool the network) and of a flow loss (to enforce local smoothness), e.g. using stadv.losses.adv_loss and stadv.losses.flow_loss, respectively. Define the final loss to be optimized as a combination of the two.
Find the flows which minimize this loss, e.g. by using an L-BFGS-B optimizer as conveniently provided in stadv.optimization.lbfgs.
An end-to-end example use of the library is provided in the notebook demo/simple_mnist.ipynb (see on GitHub).
Documentation
The documentation of the API is available at http://stadv.readthedocs.io/en/latest/stadv.html.
Testing
You can run all unit tests with
$ make init
$ make test
Metadata
Release files for stadv 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stadv-0.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for stadv-0.2.1-py2.py3-none-any.whl |
Release files / stadv-0.2.1-py2.py3-none-any.whl
| Download URL | stadv-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
d35a9ff88b8214e839d8fd0bb5d8ee0dca3c7c8986218060f547f3d7e7da2b88
|
|
BLAKE2b-256 checksum How to use checksums |
bf953b46127eb17498a1ab90f7c6bbb6cc7ff0602d08a3992b041f6b86b3b4be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|
Security for stadv 0.2.1
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.