advertorch
1.0.0
是用於對抗性魯棒性研究的Python工具箱。主要功能是在Pytorch中實現的。具體來說,廣告包含用於生成對抗性擾動和防禦對抗示例的模塊,還包含用於對抗訓練的腳本。
我們根據Python 3.6和Pytorch 1.0.0和0.4.1開發了廣告。要安裝廣告,只需運行
pip install advertorch
或克隆回購併運行
python setup.py install
要以“可編輯”模式安裝軟件包:
pip install -e .
一些攻擊對在傻瓜或聰明的實施中進行了測試,以確保正確性。目前,它們通過以下相關庫的以下版本進行了測試。
conda install -c anaconda tensorflow-gpu==1.11.0
pip install git+https://github.com/tensorflow/cleverhans.git@336b9f4ed95dccc7f0d12d338c2038c53786ab70
pip install Keras==2.2.2
pip install foolbox==1.3.2
# prepare your pytorch model as "model"
# prepare a batch of data and label as "cln_data" and "true_label"
# ...
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 )
target = torch . ones_like ( true_label ) * 3
adversary . targeted = True
adv_targeted = adversary . perturb ( cln_data , target )有關可運行的示例,請參見advertorch_examples/tutorial_attack_defense_bpda_mnist.ipynb有關如何攻擊和防禦;有關如何在MNIST上訓練強大的模型,請參見advertorch_examples/tutorial_train_mnist.py 。
文檔網頁在readThedocs上https://advertorch.readthedocs.io。
廣告仍在積極發展。我們將在路上添加以下功能/項目:
FastFeatureAttack和JacobianSaliencyMapAttack不會針對使用的Cleverhans版本進行測試。 (他們用來通過以前版本的Cleverhans進行測試。)正在研究此問題。在文件test_attacks_on_cleverhans.py中,它們在pytest測試中被標記為“跳過”。
該項目在LGPL下獲得許可。可以在許可證和許可證文件中找到條款和條件。
如果您在研究中使用Advertorch,我們會要求您引用以下技術報告:
@article{ding2019advertorch,
title={{AdverTorch} v0.1: An Adversarial Robustness Toolbox based on PyTorch},
author={Ding, Gavin Weiguang and Wang, Luyu and Jin, Xiaomeng},
journal={arXiv preprint arXiv:1902.07623},
year={2019}
}