A library for adversarial attacks on neural networks
Project description
AdversarialAttackNN
A library for adversarial attacks on neural networks. This package provides several common adversarial attack methods, including FGSM, PGD, and more, to test and evaluate the robustness of deep learning models. these are all gradient attacks
Features
- Implementations of popular adversarial attack methods (e.g., FGSM, PGD, etc.).
- Easy-to-use API for applying attacks to any PyTorch model.
- Ability to customize attack parameters (e.g., epsilon, norm, targeted vs. untargeted attacks).
- Built-in support for ensemble models.
Installation
You can install adversarialattacknn directly from GitHub using pip:
pip install git+https://github.com/yourusername/adversarialattacknn.git
Or you can install it locally by cloning the repository:
git clone https://github.com/yourusername/adversarialattacknn.git
cd adversarialattacknn
pip install -e .
USAGE
Example:
import torch
from adversarialattacknn import Attack
# Initialize the model (replace with your own model)
model = YourModel()
# Example of using the Attack class
attack = Attack(
attack='fgsm',
model_name='resnet18', # or your custom model
epsilon=0.1,
targeted=False,
random_start=True,
norm='linfty',
loss='crossentropy'
)
# Sample data (replace with actual data)
data = torch.randn((1, 3, 224, 224)) # Batch of images
label = torch.tensor([0]) # Ground-truth label
# Perform the attack
perturbation = attack(data, label)
# Apply perturbation to input data
adversarial_example = data + perturbation
-santhoshkumar
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adversarialattacknn-0.1.1.tar.gz.
File metadata
- Download URL: adversarialattacknn-0.1.1.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d738c01a93f75cd981a07d23ab595d53692e652f711c9cce39f42004ba7a64e5
|
|
| MD5 |
b1e1edd08bdcccbc5cdd2b1987f844d7
|
|
| BLAKE2b-256 |
0c0dd64fb8da6bb911d7414ca008470c9fb1b66033f665703855dcc60c62f73d
|
File details
Details for the file adversarialattacknn-0.1.1-py3-none-any.whl.
File metadata
- Download URL: adversarialattacknn-0.1.1-py3-none-any.whl
- Upload date:
- Size: 43.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98e219cc3355a906e30397235a6f5331a195b57bc9a4096f83c4c0ae9f5586b8
|
|
| MD5 |
077b120d504fb1e9a9da4ae3cda75e85
|
|
| BLAKE2b-256 |
cb7791c1bf0d3dcc21723640a86eed17b6a9b90cefbcfe85684b88c8a466793c
|