هو صندوق أدوات بيثون لأبحاث المتانة العدائية. يتم تنفيذ الوظائف الأساسية في Pytorch. على وجه التحديد ، يحتوي Advertorch على وحدات لتوليد اضطرابات عدوانية والدفاع عن أمثلة عدوانية ، وأيضًا نصوصًا للتدريب العدواني.
قمنا بتطوير Advertorch تحت Python 3.6 و Pytorch 1.0.0 و 0.4.1. لتثبيت Advertorch ، ما عليك سوى التشغيل
pip install advertorch
أو استنساخ الريبو وركض
python setup.py install
لتثبيت الحزمة في وضع "requitable":
pip install -e .
يتم اختبار بعض الهجمات ضد التطبيقات في Foolbox أو Cleverhans لضمان الصواب. حاليا ، يتم اختبارها تحت الإصدارات التالية من المكتبات ذات الصلة.
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 عن كيفية الهجوم والدفاع ؛ راجع advertorch_examples/tutorial_train_mnist.py للحصول على كيفية تدريب نموذج قوي على Mnist.
صفحة الويب الوثائقية موجودة على readthedocs https://advertorch.readthedocs.io.
لا يزال Advertorch تحت التطوير النشط. سنضيف الميزات/العناصر التالية على الطريق:
لا يجتاز 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}
}