Package documentation for DeepDefend, our Python package.
Changelog
0.1.2 (Latest): Updated PYPI project description.
0.1.1: 6 new functions.
0.1.0: Initial release.
Installation
You can install DeepDefend using PyPi, please make sure that you are using Python 3.6 or later before installing DeepDefend:
pip install deepdefend
DeepDefend is an experimental package, please be sure to report any issues, bugs, or errors you come across when using it.
Example Usage
Adversarial Attacks
import tensorflow as tf
from deepdefend.attacks import fgsm, pgd, bim, cw, deepfool, jsma
# Load a pre-trained TensorFlow model
model = ...
# Load example input and label data (replace this with your own data loading code)
x_example = ... # example input data
y_example = ... # true label
# Perform FGSM attack on the example data
adversarial_example_fgsm = fgsm(model, x_example, y_example, epsilon=0.01)
# Perform PGD attack on the example data
adversarial_example_pgd = pgd(model, x_example, y_example, epsilon=0.01, alpha=0.01, num_steps=10)
# Perform BIM attack on the example data
adversarial_example_bim = bim(model, x_example, y_example, epsilon=0.01, alpha=0.01, num_steps=10)
# Perform CW attack on the example data
adversarial_example_cw = cw(model, x_example, y_example, epsilon=0.01, c=1, kappa=0, num_steps=10, alpha=0.01)
# Perform Deepfool attack on the example data
adversarial_example_deepfool = deepfool(model, x_example, y_example, num_steps=10)
# Perform JSMA attack on the example data
adversarial_example_jsma = jsma(model, x_example, y_example, theta=0.1, gamma=0.1, num_steps=10)