Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adversarialattacknn-0.1.1.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

adversarialattacknn-0.1.1-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

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

Hashes for adversarialattacknn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d738c01a93f75cd981a07d23ab595d53692e652f711c9cce39f42004ba7a64e5
MD5 b1e1edd08bdcccbc5cdd2b1987f844d7
BLAKE2b-256 0c0dd64fb8da6bb911d7414ca008470c9fb1b66033f665703855dcc60c62f73d

See more details on using hashes here.

File details

Details for the file adversarialattacknn-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for adversarialattacknn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98e219cc3355a906e30397235a6f5331a195b57bc9a4096f83c4c0ae9f5586b8
MD5 077b120d504fb1e9a9da4ae3cda75e85
BLAKE2b-256 cb7791c1bf0d3dcc21723640a86eed17b6a9b90cefbcfe85684b88c8a466793c

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