目录

License

Code for “Automated Adversarial Training”.

Requisite

This code is implemented in PyTorch, and we have tested the code under the following environment settings:

  • python = 3.8.10
  • pytorch = 1.9.0+cu111
  • autoattack = 0.1

What is in this repository

  • auto_adv: the core codes for A², contains the super-attacker in adv_x.py, the attacker space in genotypes.py, the attack cell in cell.py, the operations in operations.py, and the Gumbel Softmax in sample.py;
  • train_[cifar10, cifar100, svhn].py: the codes for CIFAR-10, CIFAR-100, and SVHN respectively;
  • other codes: the basic code from AWP.

How to run it

For A² with a PreAct ResNet-18 on CIFAR-10 under LL_{\infty} threat model (8/255), run codes as follows,

python train_cifar10.py --data-dir DATASET_DIR --model PreActResNet18 --awp-warmup 200 

where $DATASET_DIR is the path to the dataset.

For TRADES-A² with a WRN-34-10 on CIFAR10 under LL_{\infty} threat model (8/255), run codes as follows,

python train_cifar10.py --data-dir DATASET_DIR --model WideResNet --awp-warmup 200 --loss trades

For MART-A², just set MART to $LOSS.

For AWP-A² with a WRN-34-10 on CIFAR10 under LL_{\infty} threat model (8/255), run codes as follows,

python train_cifar10.py --data-dir DATASET_DIR --model WideResNet --awp-warmup 0

To verify the effectiveness of A² further, we run attack.py to evaluate the robustness of the defense model against FGSM, PGD, C&W and AutoAttack:

python attack.py --arch $ARCH --checkpoint $CKP --preprocess meanstd --attack fgsm pgd20 cw aa

Reference Code:

关于
51.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号