Skip to main content

Foolbox Native is an adversarial attacks library that works natively with PyTorch, TensorFlow and JAX

Project description

https://badge.fury.io/py/foolbox.svg https://readthedocs.org/projects/foolbox/badge/?version=latest https://img.shields.io/badge/code%20style-black-000000.svg

Foolbox Native: A Python toolbox to create adversarial examples that fool neural networks in PyTorch, TensorFlow, and JAX

Foolbox is a Python library that let’s you easily run adversarial attacks against machine learning models like deep neural networks. It is built on top of EagerPy and works natively with models in PyTorch, TensorFlow, JAX, and NumPy.

🔥 Design

Foolbox 3 a.k.a. Foolbox Native has been rewritten from scratch using EagerPy instead of NumPy to achieve native performance on models developed in PyTorch, TensorFlow and JAX, all with one code base.

  • Native Performance: Foolbox 3 is built on top of EagerPy and runs natively in PyTorch, TensorFlow, JAX, and NumPyand comes with real batch support.

  • State-of-the-art attacks: Foolbox provides a large collection of state-of-the-art gradient-based and decision-based adversarial attacks.

  • Type Checking: Catch bugs before running your code thanks to extensive type annotations in Foolbox.

📖 Documentation

  • Guide: The best place to get started with Foolbox is the official guide.

  • Tutorial: If you are looking for a tutorial, check out this Jupyter notebook.

  • Documentaiton: Finally, you can find the full API documentation on ReadTheDocs.

🚀 Quickstart

pip install foolbox

🎉 Example

import foolbox as fb

model = ...
fmodel = fb.PyTorchModel(model, bounds=(0, 1))

attack = fb.attacks.LinfPGD()
epsilons = [0.0, 0.001, 0.01, 0.03, 0.1, 0.3, 0.5, 1.0]
_, advs, success = attack(fmodel, images, labels, epsilons=epsilons)

More examples can be found in the examples folder, e.g. a full ResNet-18 example.

📄 Citation

If you use Foolbox for your work, please cite our paper using the this BibTex entry:

@inproceedings{rauber2017foolbox,
  title={Foolbox: A Python toolbox to benchmark the robustness of machine learning models},
  author={Rauber, Jonas and Brendel, Wieland and Bethge, Matthias},
  booktitle={Reliable Machine Learning in the Wild Workshop, 34th International Conference on Machine Learning},
  year={2017},
  url={http://arxiv.org/abs/1707.04131},
}

🐍 Compatibility

We currently test with the following versions:

  • PyTorch 1.4.0

  • TensorFlow 2.1.0

  • JAX 0.1.57

  • NumPy 1.18.1

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

foolbox-3.0.4.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

foolbox-3.0.4-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file foolbox-3.0.4.tar.gz.

File metadata

  • Download URL: foolbox-3.0.4.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for foolbox-3.0.4.tar.gz
Algorithm Hash digest
SHA256 0ebf10d6f9029a87b691af89950a82a73855067d9bede9b840cb61bdc603a573
MD5 0bcebbc3644d76b4b99638423b555d1a
BLAKE2b-256 04d95856920a7072ed53748d7c08e19d3e8afd6056877d3b9f4f527f19e31163

See more details on using hashes here.

File details

Details for the file foolbox-3.0.4-py3-none-any.whl.

File metadata

  • Download URL: foolbox-3.0.4-py3-none-any.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

File hashes

Hashes for foolbox-3.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e08bd2b90263191a9e87ec4c43187317e868c701e6a483d6bf46cdf4b6d7bf7a
MD5 9ef477443d7d3c3147b556c8d02ebf72
BLAKE2b-256 1e47a7714672c8cdc79b1f9251e12122890e51ed6c6ca30716a855e9c036d2d2

See more details on using hashes here.

Supported by

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