TensorFlow implementation of Adversarial Reprogramming of Neural Networks https://arxiv.org/abs/1806.11146
- Python 2.7 or 3.x
- TensorFlow 1.4 or higher (install instructions)
- Clone this repo:
git clone [email protected]:lizhuorong/Adversarial-Reprogramming-tensorflow.git
cd Adversarial-Reprogramming-tensorflow
Download the following pre-trained models and put them into './model':
- resnet_v2_50
- inception_v3
- vgg_16
- More imagenet models can be found here
- MNIST dataset will be automatically downloaded after running the scripts.
- CIFAR-10. Training on CIFAR-10 have not been implemented yet. However, it is easy to adapt to more datasets and imagenet models.
Simply run the following command:
python main.py
You can train adversarial images for other ImageNet classifiers as well.
For example, if you want to adversarially reprogram Inception-ResNet-v2, first you need to insert from nets import inception_resnet_v2
in model.py
.
Then run:
python main.py --network_name inception_resnet_v2
- More available networks can be found in the subfolder
./nets
, which is derived from slim. - Checkpoint files will be saved in
./train
and you are able to continue training your model from the previous epoch. - Sampled images can be found in
./sample
. Following are the examples that repurposing the ImageNet classifiers to MNIST classficaion. ( top: Inception_V3 ; bottom : Resnet_v2_50)
Test will be performed immediately after training finished.
The performance of adversarially reprogramming the trained ImageNet classifiers to perform MNIST classification. Table gives test accuracy of reprogrammed networks on an MNIST classification task.
ImageNet Model | MNIST |
---|---|
Resnet_v2_50 | 0.9586 |
Inception_v3 | 0.9745 |
Code referred to a Pytorch implementation.