{"id":13418318,"url":"https://github.com/cleverhans-lab/cleverhans","last_synced_at":"2025-12-12T00:37:40.629Z","repository":{"id":43083470,"uuid":"68254498","full_name":"cleverhans-lab/cleverhans","owner":"cleverhans-lab","description":"An adversarial example library for constructing attacks, building defenses, and benchmarking both","archived":false,"fork":false,"pushed_at":"2024-04-10T13:26:10.000Z","size":9369,"stargazers_count":6297,"open_issues_count":45,"forks_count":1398,"subscribers_count":189,"default_branch":"master","last_synced_at":"2025-04-24T01:54:54.324Z","etag":null,"topics":["benchmarking","machine-learning","security"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cleverhans-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.rst","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-15T00:28:04.000Z","updated_at":"2025-04-24T01:22:09.000Z","dependencies_parsed_at":"2024-06-18T15:16:07.440Z","dependency_job_id":"99f321fd-211f-4ae1-8705-5ebd52ca9085","html_url":"https://github.com/cleverhans-lab/cleverhans","commit_stats":{"total_commits":2476,"total_committers":140,"mean_commits":"17.685714285714287","dds":0.7394991922455574,"last_synced_commit":"574efc1d2f5c7e102c78cf0e937654e847267522"},"previous_names":["tensorflow/cleverhans","openai/cleverhans"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverhans-lab%2Fcleverhans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverhans-lab%2Fcleverhans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverhans-lab%2Fcleverhans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleverhans-lab%2Fcleverhans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleverhans-lab","download_url":"https://codeload.github.com/cleverhans-lab/cleverhans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990460,"owners_count":21995774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmarking","machine-learning","security"],"created_at":"2024-07-30T22:01:00.998Z","updated_at":"2025-12-12T00:37:40.582Z","avatar_url":"https://github.com/cleverhans-lab.png","language":"Jupyter Notebook","funding_links":[],"categories":["Deep Learning","🛡️ Adversarial Testing","Robustness Toolboxes","Jupyter Notebook","Open Source Security Tools","Adversarial Attacks","Deep Learning Framework","对抗学习与鲁棒性","Safety and Security Testing","Technical Resources","LLM SECURITY / AI SECURITY","Data Science","2. Adversarial Machine Learning","Attack Techniques \u0026 Red Teaming","Table of Contents","Adversarial Machine Learning","Security and robustness"],"sub_categories":["Interpretability \u0026 Adversarial Training","Adversarial Testing","Open Source/Access Responsible AI Software Packages","AI Red Teaming \u0026 Adversarial Testing","Machine Learning","2.1 Toolkits \u0026 Libraries","Adversarial ML \u0026 Classical Models","🤖 AI Security / AI Red Teaming"],"readme":"# CleverHans (latest release: v4.0.0)\n\n\u003cimg src=\"https://github.com/tensorflow/cleverhans/blob/master/assets/logo.png?raw=true\" alt=\"cleverhans logo\"\u003e\n\n\nThis repository contains the source code for CleverHans, a Python library to\nbenchmark machine learning systems' vulnerability to\n[adversarial examples](http://karpathy.github.io/2015/03/30/breaking-convnets/).\nYou can learn more about such vulnerabilities on the accompanying [blog](http://cleverhans.io).\n\nThe CleverHans library is under continual development, always welcoming\n[contributions](https://github.com/cleverhans-lab/cleverhans#contributing)\nof the latest attacks and defenses.\nIn particular, we always welcome help towards resolving the [issues](https://github.com/cleverhans-lab/cleverhans/issues)\ncurrently open.\n\nSince v4.0.0, CleverHans supports 3 frameworks: JAX, PyTorch, and TF2. We are currently prioritizing implementing \nattacks in PyTorch, but we very much welcome contributions for all 3 frameworks. In versions v3.1.0 and prior,\nCleverHans supported TF1; the code for v3.1.0 can be found under `cleverhans_v3.1.0/` or by checking\nout a prior Github release.\n\nThe library focuses on providing reference implementation of attacks\nagainst machine learning models to help with benchmarking models against\nadversarial examples. \n\nThe directory structure is as follows: \n`cleverhans/` contain attack implementations, `tutorials/` contain scripts demonstrating the features\nof CleverHans, and `defenses/` contains defense implementations. Each framework has its own subdirectory\nwithin these folders, e.g. `cleverhans/jax`.\n\n## Setting up CleverHans\n\n### Dependencies\n\nThis library uses [Jax](https://github.com/google/jax), [PyTorch](https://pytorch.org/) or [TensorFlow 2](https://www.tensorflow.org/) to accelerate graph\ncomputations performed by many machine learning models.\nTherefore, installing one of these libraries is a pre-requisite.\n\n### Installation\n\nOnce dependencies have been taken care of, you can install CleverHans using\n`pip` or by cloning this Github repository.\n\n#### `pip` installation\n\nIf you are installing CleverHans using `pip`, run the following command:\n\n```\npip install cleverhans\n```\n\nThis will install the last version uploaded to\n[Pypi](https://pypi.org/project/cleverhans).\nIf you'd instead like to install the bleeding edge version, use:\n\n```\npip install git+https://github.com/cleverhans-lab/cleverhans.git#egg=cleverhans\n```\n\n#### Installation for development\n\nIf you want to make an editable installation of CleverHans so that you can\ndevelop the library and contribute changes back, first fork the repository\non GitHub and then clone your fork into a directory of your choice:\n\n```\ngit clone https://github.com/\u003cyour-org\u003e/cleverhans\n```\n\nYou can then install the local package in \"editable\" mode in order to add it to\nyour `PYTHONPATH`:\n\n```\ncd cleverhans\npip install -e .\n```\n\n### Currently supported setups\n\nAlthough CleverHans is likely to work on many other machine configurations, we\ncurrently test it with Python\n3.6, Jax 0.2, PyTorch 1.7, and Tensorflow 2.4 on Ubuntu 18.04 LTS (Bionic Beaver).\n\n## Getting support\n\nIf you have a request for support, please ask a question\non [StackOverflow](https://stackoverflow.com/questions/tagged/cleverhans)\nrather than opening an issue in the GitHub tracker. The GitHub\nissue tracker should *only* be used to report bugs or make feature requests.\n\n## Contributing\n\nContributions are welcomed! To speed the code review process, we ask that:\n* New efforts and features be coordinated on the [discussion board](https://github.com/cleverhans-lab/cleverhans/discussions).\n* When making code contributions to CleverHans, you should follow the [`Black`](https://black.readthedocs.io/en/stable/index.html)\n coding style in your pull requests.\n* We do not accept pull requests that add git submodules because of [the\n  problems that arise when maintaining git\n  submodules](https://medium.com/@porteneuve/mastering-git-submodules-34c65e940407).\n\nBug fixes can be initiated through Github pull requests.\n\n## Tutorials: `tutorials` directory\n\nTo help you get started with the functionalities provided by this library, the\n`tutorials/` folder comes with the following tutorials:\n* **MNIST with FGSM and PGD** ([jax](tutorials/jax/mnist_tutorial.py), [tf2](tutorials/tf2/mnist_tutorial.py):\nthis tutorial covers how to train an MNIST model and craft adversarial examples using the\n [fast gradient sign method](https://arxiv.org/abs/1412.6572) and \n [projected gradient descent](https://arxiv.org/abs/1706.06083).\n* **CIFAR10 with FGSM and PGD** ([pytorch](tutorials/torch/cifar10_tutorial.py), [tf2](tutorials/tf2/cifar10_tutorial.py)):\nthis tutorial covers how to train a CIFAR10 model and \ncraft adversarial examples using the [fast gradient sign method](https://arxiv.org/abs/1412.6572) and\n [projected gradient descent](https://arxiv.org/abs/1706.06083).\n\nNOTE: the tutorials are maintained carefully, in the sense that we use\ncontinuous integration to make sure they continue working. They are not\nconsidered part of the API and they can change at any time without warning.\nYou should not write 3rd party code that imports the tutorials and expect\nthat the interface will not break. Only the main library is subject to\nour six month interface deprecation warning rule.\n\nNOTE: please start a thread on the [discussion board](https://github.com/cleverhans-lab/cleverhans/discussions) before writing a new\ntutorial. Because each new tutorial involves a large amount of duplicated\ncode relative to the existing tutorials, and because every line of code\nrequires ongoing testing and maintenance indefinitely, we generally prefer\nnot to add new tutorials. Each tutorial should showcase an extremely different\nway of using the library. Just calling a different attack, model, or dataset\nis not enough to justify maintaining a parallel tutorial.\n\n## Examples : `examples` directory\n\nThe `examples/` folder contains additional scripts to showcase different uses\nof the CleverHans library or get you started competing in different adversarial\nexample contests. We do not offer nearly as much ongoing maintenance or support\nfor this directory as the rest of the library, and if code in here gets broken\nwe may just delete it without warning.\n\nSince we recently discontinued support for TF1, the `examples/` folder is currently \nempty, but you are welcome to submit your uses via a pull request :)\n\nOld examples for CleverHans v3.1.0 and prior can be found under `cleverhans_v3.1.0/examples/`.\n\n## Reporting benchmarks\n\nWhen reporting benchmarks, please:\n* Use a versioned release of CleverHans. You can find a list of released versions [here](https://github.com/cleverhans-lab/cleverhans/releases).\n* Either use the latest version, or, if comparing to an earlier publication, use the same version as the earlier publication.\n* Report which attack method was used.\n* Report any configuration variables used to determine the behavior of the attack.\n\nFor example, you might report \"We benchmarked the robustness of our method to\nadversarial attack using v4.0.0 of CleverHans. On a test set modified by the\n`FastGradientMethod` with a max-norm `eps` of 0.3, we obtained a test set accuracy of 71.3%.\"\n\n## Citing this work\n\nIf you use CleverHans for academic research, you are highly encouraged\n(though not required) to cite the following [paper](https://arxiv.org/abs/1610.00768):\n\n```\n@article{papernot2018cleverhans,\n  title={Technical Report on the CleverHans v2.1.0 Adversarial Examples Library},\n  author={Nicolas Papernot and Fartash Faghri and Nicholas Carlini and\n  Ian Goodfellow and Reuben Feinman and Alexey Kurakin and Cihang Xie and\n  Yash Sharma and Tom Brown and Aurko Roy and Alexander Matyasko and\n  Vahid Behzadan and Karen Hambardzumyan and Zhishuai Zhang and\n  Yi-Lin Juang and Zhi Li and Ryan Sheatsley and Abhibhav Garg and\n  Jonathan Uesato and Willi Gierke and Yinpeng Dong and David Berthelot and\n  Paul Hendricks and Jonas Rauber and Rujun Long},\n  journal={arXiv preprint arXiv:1610.00768},\n  year={2018}\n}\n```\n\n## About the name\n\nThe name CleverHans is a reference to a presentation by Bob Sturm titled\n“Clever Hans, Clever Algorithms: Are Your Machine Learnings Learning What You\nThink?\" and the corresponding publication, [\"A Simple Method to Determine if a\nMusic Information Retrieval System is a\n'Horse'.\"](http://ieeexplore.ieee.org/document/6847693/) Clever Hans was a\nhorse that appeared to have learned to answer arithmetic questions, but had in\nfact only learned to read social cues that enabled him to give the correct\nanswer. In controlled settings where he could not see people's faces or receive\nother feedback, he was unable to answer the same questions. The story of Clever\nHans is a metaphor for machine learning systems that may achieve very high\naccuracy on a test set drawn from the same distribution as the training data,\nbut that do not actually understand the underlying task and perform poorly on\nother inputs.\n\n## Authors\n\nThis library is collectively maintained by the [CleverHans Lab](https://cleverhans-lab.github.io/) \nat the University of Toronto. The current point of contact is Jonas Guan. \nIt was previously maintained by Ian Goodfellow and Nicolas Papernot.\n\n\nThe following authors contributed 100 lines or more (ordered according to the GitHub contributors page):\n* Ian Goodfellow (Google Brain)\n* Nicolas Papernot (Google Brain)\n* Nicholas Carlini (Google Brain)\n* Fartash Faghri (University of Toronto)\n* Tzu-Wei Sung (National Taiwan University)\n* Alexey Kurakin (Google Brain)\n* Reuben Feinman (New York University)\n* Shiyu Duan (University of Florida)\n* Phani Krishna (Video Analytics Lab)\n* David Berthelot (Google Brain)\n* Tom Brown (Google Brain)\n* Cihang Xie (Johns Hopkins)\n* Yash Sharma (The Cooper Union)\n* Aashish Kumar (HARMAN X)\n* Aurko Roy (Google Brain)\n* Alexander Matyasko (Nanyang Technological University)\n* Anshuman Suri (University of Virginia)\n* Yen-Chen Lin (MIT)\n* Vahid Behzadan (Kansas State)\n* Jonathan Uesato (DeepMind)\n* Florian Tramèr (Stanford University)\n* Haojie Yuan (University of Science \u0026 Technology of China)\n* Zhishuai Zhang (Johns Hopkins)\n* Karen Hambardzumyan (YerevaNN)\n* Jianbo Chen (UC Berkeley)\n* Catherine Olsson (Google Brain)\n* Aidan Gomez (University of Oxford)\n* Zhi Li (University of Toronto)\n* Yi-Lin Juang (NTUEE)\n* Pratyush Sahay (formerly HARMAN X)\n* Abhibhav Garg (IIT Delhi)\n* Aditi Raghunathan (Stanford University)\n* Yang Song (Stanford University)\n* Riccardo Volpi (Italian Institute of Technology)\n* Angus Galloway (University of Guelph)\n* Yinpeng Dong (Tsinghua University)\n* Willi Gierke (Hasso Plattner Institute)\n* Bruno López\n* Jonas Rauber (IMPRS)\n* Paul Hendricks (NVIDIA)\n* Ryan Sheatsley (Pennsylvania State University)\n* Rujun Long (0101.AI)\n* Bogdan Kulynych (EPFL)\n* Erfan Noury (UMBC)\n* Robert Wagner (Case Western Reserve University)\n* Erh-Chung Chen (National Tsing Hua University)\n* Joel Frank (Ruhr-University Bochum)\n\n## Copyright\n\nCopyright 2021 - Google Inc., OpenAI, Pennsylvania State University, University of Toronto.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleverhans-lab%2Fcleverhans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleverhans-lab%2Fcleverhans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleverhans-lab%2Fcleverhans/lists"}