https://github.com/cleverhans-lab/cleverhans

An adversarial example library for constructing attacks, building defenses, and benchmarking both

https://github.com/cleverhans-lab/cleverhans

Science Score: 33.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org, ieee.org
  • Committers with academic emails
    23 of 130 committers (17.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.6%) to scientific vocabulary

Keywords

benchmarking machine-learning security

Keywords from Contributors

reinforcement-learning distributed tensor deep-neural-networks optimizing-compiler autograd jax gym transpiler theano
Last synced: 6 months ago · JSON representation

Repository

An adversarial example library for constructing attacks, building defenses, and benchmarking both

Basic Info
  • Host: GitHub
  • Owner: cleverhans-lab
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage:
  • Size: 8.93 MB
Statistics
  • Stars: 6,354
  • Watchers: 188
  • Forks: 1,403
  • Open Issues: 45
  • Releases: 8
Topics
benchmarking machine-learning security
Created over 9 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Contributing License Code of conduct

README.md

CleverHans (latest release: v4.0.0)

cleverhans logo

This repository contains the source code for CleverHans, a Python library to benchmark machine learning systems' vulnerability to adversarial examples. You can learn more about such vulnerabilities on the accompanying blog.

The CleverHans library is under continual development, always welcoming contributions of the latest attacks and defenses. In particular, we always welcome help towards resolving the issues currently open.

Since v4.0.0, CleverHans supports 3 frameworks: JAX, PyTorch, and TF2. We are currently prioritizing implementing attacks in PyTorch, but we very much welcome contributions for all 3 frameworks. In versions v3.1.0 and prior, CleverHans supported TF1; the code for v3.1.0 can be found under cleverhans_v3.1.0/ or by checking out a prior Github release.

The library focuses on providing reference implementation of attacks against machine learning models to help with benchmarking models against adversarial examples.

The directory structure is as follows: cleverhans/ contain attack implementations, tutorials/ contain scripts demonstrating the features of CleverHans, and defenses/ contains defense implementations. Each framework has its own subdirectory within these folders, e.g. cleverhans/jax.

Setting up CleverHans

Dependencies

This library uses Jax, PyTorch or TensorFlow 2 to accelerate graph computations performed by many machine learning models. Therefore, installing one of these libraries is a pre-requisite.

Installation

Once dependencies have been taken care of, you can install CleverHans using pip or by cloning this Github repository.

pip installation

If you are installing CleverHans using pip, run the following command:

pip install cleverhans

This will install the last version uploaded to Pypi. If you'd instead like to install the bleeding edge version, use:

pip install git+https://github.com/cleverhans-lab/cleverhans.git#egg=cleverhans

Installation for development

If you want to make an editable installation of CleverHans so that you can develop the library and contribute changes back, first fork the repository on GitHub and then clone your fork into a directory of your choice:

git clone https://github.com/<your-org>/cleverhans

You can then install the local package in "editable" mode in order to add it to your PYTHONPATH:

cd cleverhans pip install -e .

Currently supported setups

Although CleverHans is likely to work on many other machine configurations, we currently test it with Python 3.6, Jax 0.2, PyTorch 1.7, and Tensorflow 2.4 on Ubuntu 18.04 LTS (Bionic Beaver).

Getting support

If you have a request for support, please ask a question on StackOverflow rather than opening an issue in the GitHub tracker. The GitHub issue tracker should only be used to report bugs or make feature requests.

Contributing

Contributions are welcomed! To speed the code review process, we ask that: * New efforts and features be coordinated on the discussion board. * When making code contributions to CleverHans, you should follow the Black coding style in your pull requests. * We do not accept pull requests that add git submodules because of the problems that arise when maintaining git submodules.

Bug fixes can be initiated through Github pull requests.

Tutorials: tutorials directory

To help you get started with the functionalities provided by this library, the tutorials/ folder comes with the following tutorials: * MNIST with FGSM and PGD (jax, tf2: this tutorial covers how to train an MNIST model and craft adversarial examples using the fast gradient sign method and projected gradient descent. * CIFAR10 with FGSM and PGD (pytorch, tf2): this tutorial covers how to train a CIFAR10 model and craft adversarial examples using the fast gradient sign method and projected gradient descent.

NOTE: the tutorials are maintained carefully, in the sense that we use continuous integration to make sure they continue working. They are not considered part of the API and they can change at any time without warning. You should not write 3rd party code that imports the tutorials and expect that the interface will not break. Only the main library is subject to our six month interface deprecation warning rule.

NOTE: please start a thread on the discussion board before writing a new tutorial. Because each new tutorial involves a large amount of duplicated code relative to the existing tutorials, and because every line of code requires ongoing testing and maintenance indefinitely, we generally prefer not to add new tutorials. Each tutorial should showcase an extremely different way of using the library. Just calling a different attack, model, or dataset is not enough to justify maintaining a parallel tutorial.

Examples : examples directory

The examples/ folder contains additional scripts to showcase different uses of the CleverHans library or get you started competing in different adversarial example contests. We do not offer nearly as much ongoing maintenance or support for this directory as the rest of the library, and if code in here gets broken we may just delete it without warning.

Since we recently discontinued support for TF1, the examples/ folder is currently empty, but you are welcome to submit your uses via a pull request :)

Old examples for CleverHans v3.1.0 and prior can be found under cleverhans_v3.1.0/examples/.

Reporting benchmarks

When reporting benchmarks, please: * Use a versioned release of CleverHans. You can find a list of released versions here. * Either use the latest version, or, if comparing to an earlier publication, use the same version as the earlier publication. * Report which attack method was used. * Report any configuration variables used to determine the behavior of the attack.

For example, you might report "We benchmarked the robustness of our method to adversarial attack using v4.0.0 of CleverHans. On a test set modified by the FastGradientMethod with a max-norm eps of 0.3, we obtained a test set accuracy of 71.3%."

Citing this work

If you use CleverHans for academic research, you are highly encouraged (though not required) to cite the following paper:

@article{papernot2018cleverhans, title={Technical Report on the CleverHans v2.1.0 Adversarial Examples Library}, author={Nicolas Papernot and Fartash Faghri and Nicholas Carlini and Ian Goodfellow and Reuben Feinman and Alexey Kurakin and Cihang Xie and Yash Sharma and Tom Brown and Aurko Roy and Alexander Matyasko and Vahid Behzadan and Karen Hambardzumyan and Zhishuai Zhang and Yi-Lin Juang and Zhi Li and Ryan Sheatsley and Abhibhav Garg and Jonathan Uesato and Willi Gierke and Yinpeng Dong and David Berthelot and Paul Hendricks and Jonas Rauber and Rujun Long}, journal={arXiv preprint arXiv:1610.00768}, year={2018} }

About the name

The name CleverHans is a reference to a presentation by Bob Sturm titled “Clever Hans, Clever Algorithms: Are Your Machine Learnings Learning What You Think?" and the corresponding publication, "A Simple Method to Determine if a Music Information Retrieval System is a 'Horse'." Clever Hans was a horse that appeared to have learned to answer arithmetic questions, but had in fact only learned to read social cues that enabled him to give the correct answer. In controlled settings where he could not see people's faces or receive other feedback, he was unable to answer the same questions. The story of Clever Hans is a metaphor for machine learning systems that may achieve very high accuracy on a test set drawn from the same distribution as the training data, but that do not actually understand the underlying task and perform poorly on other inputs.

Authors

This library is collectively maintained by the CleverHans Lab at the University of Toronto. The current point of contact is Jonas Guan. It was previously maintained by Ian Goodfellow and Nicolas Papernot.

The following authors contributed 100 lines or more (ordered according to the GitHub contributors page): * Ian Goodfellow (Google Brain) * Nicolas Papernot (Google Brain) * Nicholas Carlini (Google Brain) * Fartash Faghri (University of Toronto) * Tzu-Wei Sung (National Taiwan University) * Alexey Kurakin (Google Brain) * Reuben Feinman (New York University) * Shiyu Duan (University of Florida) * Phani Krishna (Video Analytics Lab) * David Berthelot (Google Brain) * Tom Brown (Google Brain) * Cihang Xie (Johns Hopkins) * Yash Sharma (The Cooper Union) * Aashish Kumar (HARMAN X) * Aurko Roy (Google Brain) * Alexander Matyasko (Nanyang Technological University) * Anshuman Suri (University of Virginia) * Yen-Chen Lin (MIT) * Vahid Behzadan (Kansas State) * Jonathan Uesato (DeepMind) * Florian Tramèr (Stanford University) * Haojie Yuan (University of Science & Technology of China) * Zhishuai Zhang (Johns Hopkins) * Karen Hambardzumyan (YerevaNN) * Jianbo Chen (UC Berkeley) * Catherine Olsson (Google Brain) * Aidan Gomez (University of Oxford) * Zhi Li (University of Toronto) * Yi-Lin Juang (NTUEE) * Pratyush Sahay (formerly HARMAN X) * Abhibhav Garg (IIT Delhi) * Aditi Raghunathan (Stanford University) * Yang Song (Stanford University) * Riccardo Volpi (Italian Institute of Technology) * Angus Galloway (University of Guelph) * Yinpeng Dong (Tsinghua University) * Willi Gierke (Hasso Plattner Institute) * Bruno López * Jonas Rauber (IMPRS) * Paul Hendricks (NVIDIA) * Ryan Sheatsley (Pennsylvania State University) * Rujun Long (0101.AI) * Bogdan Kulynych (EPFL) * Erfan Noury (UMBC) * Robert Wagner (Case Western Reserve University) * Erh-Chung Chen (National Tsing Hua University) * Joel Frank (Ruhr-University Bochum)

Copyright

Copyright 2021 - Google Inc., OpenAI, Pennsylvania State University, University of Toronto.

Owner

  • Name: CleverHans Lab
  • Login: cleverhans-lab
  • Kind: organization
  • Location: Toronto, Canada

GitHub Events

Total
  • Issues event: 1
  • Watch event: 188
  • Issue comment event: 1
  • Pull request event: 1
  • Fork event: 20
Last Year
  • Issues event: 1
  • Watch event: 188
  • Issue comment event: 1
  • Pull request event: 1
  • Fork event: 20

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 2,476
  • Total Committers: 130
  • Avg Commits per committer: 19.046
  • Development Distribution Score (DDS): 0.739
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Ian Goodfellow g****w@g****m 645
npapernot n****6@c****u 526
Nicholas Carlini n****s@c****m 195
Fartash Faghri f****i@g****m 184
Ian Goodfellow g****n@g****m 73
michaelshiyu m****3@g****m 51
Stephan Rabanser s****n@c****u 51
Alexey Kurakin k****n@g****m 47
WindQAQ w****q@g****m 41
Reuben Feinman r****6@g****m 38
Yao Qin y****7@e****u 35
Jonas j****s@c****u 35
Phani Krishna k****g@g****m 34
dberth d****h@g****m 31
nottombrown n****n@g****m 24
cihangxie c****8@j****u 20
Yash Sharma y****6@g****m 19
Aashish Kumar k****h@g****m 16
Joel Frank j****k@r****e 15
iarunava l****a@g****m 13
LorenzHW l****w@g****m 12
catherio c****o@m****u 11
Haojie Yuan h****n@g****m 11
Aurko Roy a****r@g****m 11
Jianbo Chen j****n@b****u 10
Alexander Matyasko a****o@g****m 10
Nicholas Frosst f****t@g****m 9
Anshuman Suri i****2 9
Florian Tramer f****r@g****m 9
YenChenLin y****4@g****m 9
and 100 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 58
  • Total pull requests: 52
  • Average time to close issues: over 1 year
  • Average time to close pull requests: 6 months
  • Total issue authors: 40
  • Total pull request authors: 39
  • Average comments per issue: 2.52
  • Average comments per pull request: 1.92
  • Merged pull requests: 29
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • goodfeli (17)
  • RSMung (2)
  • AbdulMustafa97 (2)
  • grahamannett (1)
  • litvand (1)
  • ForeverRuri (1)
  • cassidylaidlaw (1)
  • AsWali (1)
  • sethbeckett (1)
  • ananthceh19 (1)
  • thijs-vanweezel (1)
  • GuanxiongLiu (1)
  • YutianPangASU (1)
  • tekeuange23 (1)
  • ChanghunHyun (1)
Pull Request Authors
  • npapernot (3)
  • CNOCycle (3)
  • jonasguan (3)
  • destinl (2)
  • axantillon (2)
  • AxelBohm (2)
  • Joool (2)
  • alkaet (2)
  • iamgroot42 (2)
  • ben-zoo (2)
  • Lastsource (2)
  • steverab (2)
  • tejuafonja (2)
  • iArunava (2)
  • gilfidel (1)
Top Labels
Issue Labels
version < 4 (13) hackathon (7) help wanted (3) enhancement (2) bug (1) wontfix (1) waiting for tensorflow (1)
Pull Request Labels
waiting for contributor (3) version < 4 (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 1,707 last-month
  • Total docker downloads: 63
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 134
    (may contain duplicates)
  • Total versions: 11
  • Total maintainers: 2
pypi.org: cleverhans
  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 134
  • Downloads: 1,707 Last month
  • Docker Downloads: 63
Rankings
Stargazers count: 0.4%
Forks count: 1.1%
Dependent repos count: 1.3%
Average: 2.9%
Docker downloads count: 3.0%
Dependent packages count: 4.8%
Downloads: 6.7%
Maintainers (2)
Last synced: 6 months ago
proxy.golang.org: github.com/cleverhans-lab/cleverhans
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago

Dependencies

cleverhans_v3.1.0/docsource/docs_requirements.txt pypi
  • tensorflow *
cleverhans_v3.1.0/examples/robust_vision_benchmark/cleverhans_attack_example/requirements.txt pypi
  • numpy *
  • tensorflow *
cleverhans_v3.1.0/setup.py pypi
  • joblib *
  • matplotlib *
  • mnist *
  • nose *
  • numpy *
  • pycodestyle *
  • scipy *
  • tensorflow-probability *
docsource/docs_requirements.txt pypi
  • tensorflow *
requirements/requirements-dev.txt pypi
  • black >=20.8b1 development
  • flake8 >=3.8.0 development
  • mypy >=0.790 development
  • mypy-extensions >=0.4.3 development
  • pre-commit >=2.9.0 development
  • pytest >=6.2.0 development
requirements/requirements-gpu.txt pypi
  • jaxlib >=0.1.60
requirements/requirements-jax.txt pypi
  • jax >=0.2.8
  • jaxlib >=0.1.60
requirements/requirements-pytorch.txt pypi
  • torch >=1.7.0
  • torchvision >=0.8.2
requirements/requirements-tf2.txt pypi
  • tensorflow >=2.3.0
  • tensorflow-datasets >=4.2.0
requirements/requirements.txt pypi
  • absl-py >=0.10.0
  • easydict >=1.9
  • numpy >=1.19.0
  • requests >=2.25.0
  • scipy >=1.5.0
setup.py pypi
  • absl-py *
  • easydict *
  • joblib *
  • matplotlib *
  • mnist *
  • nose *
  • numpy *
  • pycodestyle *
  • scipy *
  • six *
  • tensorflow-probability *
.github/workflows/style_type_check.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/tests-pytorch.yml actions
  • actions/checkout v2 composite
.github/workflows/tutorials-jax.yml actions
  • actions/checkout v2 composite
.github/workflows/tutorials-pytorch.yml actions
  • actions/checkout v2 composite
.github/workflows/tutorials-tf2.yml actions
  • actions/checkout v2 composite
Dockerfile docker
  • ubuntu 14.04 build
cleverhans_v3.1.0/Dockerfile docker
  • ubuntu 14.04 build
cleverhans_v3.1.0/examples/robust_vision_benchmark/cleverhans_attack_example/Dockerfile docker
  • python 3.6 build