advertorch
by BorealisAI
AdverTorch is a PyTorch-based toolbox designed to generate adversarial perturbations and defend machine learning models against adversarial attacks for robustness research.
A Toolbox for Adversarial Robustness Research
Primary Use Case
This tool is primarily used by AI security researchers and practitioners to evaluate and improve the adversarial robustness of machine learning models. It enables users to create adversarial examples, implement defenses, and perform adversarial training to enhance model security against exploitation.
- Modules for generating adversarial perturbations
- Defenses against adversarial examples
- Scripts for adversarial training of robust models
- Implemented primarily in PyTorch
- Compatibility testing with Foolbox and CleverHans frameworks
- Support for both targeted and untargeted attacks
- Active development with plans for multi-framework support
- Comprehensive examples and tutorials included
Installation
- pip install advertorch
- git clone the repository and run python setup.py install
- pip install -e . to install in editable mode
- Install TensorFlow GPU 1.11.0 via conda for testing environments
- pip install CleverHans from specific git commit
- pip install Keras version 2.2.2
- pip install Foolbox version 1.3.2
Usage
>_ pip install advertorchInstalls the AdverTorch package via pip.
>_ python setup.py installInstalls AdverTorch from the cloned repository.
>_ pip install -e .Installs AdverTorch in editable mode for development.
>_ from advertorch.attacks import LinfPGDAttack
adversary = LinfPGDAttack(model, loss_fn=nn.CrossEntropyLoss(reduction="sum"), eps=0.3, nb_iter=40, eps_iter=0.01, rand_init=True, clip_min=0.0, clip_max=1.0, targeted=False)
adv_untargeted = adversary.perturb(cln_data, true_label)Creates an untargeted PGD adversarial attack on a PyTorch model.
>_ adversary.targeted = True
target = torch.ones_like(true_label) * 3
adv_targeted = adversary.perturb(cln_data, target)Switches the attack to targeted mode and generates targeted adversarial examples.
>_ See advertorch_examples/tutorial_attack_defense_bpda_mnist.ipynbExample notebook demonstrating how to perform attacks and defenses using AdverTorch.
>_ See advertorch_examples/tutorial_train_mnist.pyExample script showing how to adversarially train a robust model on MNIST.
- Integrate AdverTorch into ML model development pipelines for continuous adversarial robustness testing.
- Use adversarial example generation to simulate attacker behavior during red team exercises.
- Leverage adversarial training scripts to harden models proactively as part of blue team defense.
- Combine with threat intelligence to tailor adversarial attacks reflecting real-world tactics.
- Expand tool support to TensorFlow and other frameworks to cover diverse AI environments.
Docs Take 2 Hours. AI Takes 10 Seconds.
Ask anything about advertorch. Installation? Config? Troubleshooting? Get answers trained on real docs and GitHub issues—not generic ChatGPT fluff.
This tool hasn't been indexed yet. Request indexing to enable AI chat.
Admin will review your request within 24 hours
Related Tools
CL4R1T4S
elder-plinius/CL4R1T4S
LEAKED SYSTEM PROMPTS FOR CHATGPT, GEMINI, GROK, CLAUDE, PERPLEXITY, CURSOR, DEVIN, REPLIT, AND MORE! - AI SYSTEMS TRANSPARENCY FOR ALL! 👐
cleverhans
cleverhans-lab/cleverhans
An adversarial example library for constructing attacks, building defenses, and benchmarking both
TextAttack
QData/TextAttack
TextAttack 🐙 is a Python framework for adversarial attacks, data augmentation, and model training in NLP https://textattack.readthedocs.io/en/master/
AI-Infra-Guard
Tencent/AI-Infra-Guard
A.I.G (AI-Infra-Guard) is a comprehensive, intelligent, and easy-to-use AI Red Teaming platform developed by Tencent Zhuque Lab.
mcp-containers
metorial/mcp-containers
Metorial MCP Containers - Containerized versions of hundreds of MCP servers 📡 🧠
nlp
duoergun0729/nlp
兜哥出品 <一本开源的NLP入门书籍>
