This repository include the code for "Boosting the Transferability of Adversarial Examples via Stochastic Serial Attack"
We propose a novel attack strategy called stochastic serial attack (SSA). It adopts a serial strategy to attack local models, which reduces memory consumption compared to parallel attacks. Moreover, since local models are stochastically selected from a large model set, it can ensure that the adversarial examples do not overfit specific weaknesses of local source models.
If you use Stochastic Series Attack in your research, please consider citing
-
git clone https://github.com/haolingguang/SSA.git -
Install dependencies:
Python >= 3.6
Pytorch >=1.3
pip install pretrainedmodels
pretrainedmodels is a pretrained models repository of pytorch, which include all pytorch models used in our paper. -
archiveinclude the dataset in NeurIPS 2017 adversarial competition. If you want useImageNet, you need download corresponding dataset and usetorchvision.datasets.ImageFolderto load dataset. -
run attack
python SSA.py -
If you need load adversarial training models, you need use https://github.com/haolingguang/tensorflow-to-pytorch.git to convert tensorflow's pre-training models to pytorch's
-
In order to get the mini-ImageNet, you can refer to https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/tree/master/pytorch_classification/mini_imagenet
-
Create attack dataset for the models trained by mini-ImageNet, you need run
Rename_image.pyinmini_dataset.
Package pretrainedmodels maybe have some problem, But you can use another pytorch model package timm
For example: parallel computing
import timm
t = timm.create_model('resnet50', num_classes=1000, pretrained=True)
t = torch.nn.DataParallel(t).cuda()