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.0.tar.gz (18.5 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.0-py3-none-any.whl (41.1 kB view details)

Uploaded Python 3

File details

Details for the file adversarialattacknn-0.1.0.tar.gz.

File metadata

  • Download URL: adversarialattacknn-0.1.0.tar.gz
  • Upload date:
  • Size: 18.5 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.0.tar.gz
Algorithm Hash digest
SHA256 69e5ee0a9f95a0096ef1ccdf89805e71acce557eef2562d0ecc5b60e2a4d2997
MD5 b8e14c6ef9c340d7dccbe8e3c742d86d
BLAKE2b-256 8e9ed20cbe8f233bf3b143982cb87f7593b50095a7858342a8ab3872639301d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adversarialattacknn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1dc7c0ea4b5b6debb27dd9371d251ad3ff427ed72e2b5ea8a77f30b74cf150e
MD5 13608a956640d48864696d355efc15a8
BLAKE2b-256 ff69c157ebd5357032ea36e2189b87ec5b8573aa0b1033fe4deca8d6d879319a

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