pip install -r requirements.txtFor Tiny-ImageNet, download the dataset and place it at tinyimagenet/resnet32/data/tiny-imagenet-200 and tinyimagenet/vgg16/data/tiny-imagenet-200.
Train and apply the defense for each dataset and architecture:
cd cifar10
python train.py --arch resnet32
python train.py --arch vgg16
cd ../cifar100
python train.py --arch resnet32
python train.py --arch vgg16
cd ../tinyimagenet
python train.py --arch resnet32
python train.py --arch vgg16Checkpoints are saved to {arch}/checkpoint/. The defended model is saved as defended.pth.
Evaluate the defended model and compute the ARI threshold:
cd cifar10
python validate.py --arch resnet32
python validate.py --arch vgg16
cd ../cifar100
python validate.py --arch resnet32
python validate.py --arch vgg16
cd ../tinyimagenet
python validate.py --arch resnet32
python validate.py --arch vgg16Each attack directory is named {attack}/{arch}-{dataset}/ and contains five scripts. Run from inside the directory.
cd ProFlip/resnet32-cifar10
python nonadaptive.py
python adaptive.py
python trigger_nonadaptive.py
python trigger_adaptive.pycd P3A/resnet32-cifar10
python nonadaptive.py
python adaptive.py
python trigger_nonadaptive.py
python trigger_adaptive.pycd APA/resnet32-cifar10
python nonadaptive.py
python adaptive.py
python trigger_nonadaptive.py
python trigger_adaptive.pyReplace resnet32-cifar10 with any of:
resnet32-cifar100resnet32-tinyimagenetvgg16-cifar10vgg16-cifar100vgg16-tinyimagenet
Results are saved to ./result/ inside each attack directory.