GithubHelp home page GithubHelp logo

prinsphield / adversarial_reprogramming Goto Github PK

View Code? Open in Web Editor NEW
33.0 4.0 4.0 20 KB

Adversarial Reprogramming of Neural Networks

Home Page: https://arxiv.org/abs/1806.11146

License: MIT License

Python 100.00%

adversarial_reprogramming's Introduction

Adversarial Reprogramming

Introduction

This repo is a pytorch implementation of the paper. We aim to reprogram the pretrained imagenet models for MNIST classification. Following the code, you can easily add more datasets and other pretrained imagenet models for more experiments.

  • The main_raw.py is the rough version from scratch.
  • The main_single.py is the old version that is only able to train on a single gpu card.
  • The main.py is the final version that supports multi-gpu training.

Requirements

Training

  1. Download pretrained imagenet models.

    ./download.py
    
  2. The MNIST dataset will be automatically downloaded after running the scripts. Then, the structure of this repo should be as follows.

    ├── datasets
    │   └── mnist
    │       ├── processed
    │       │   ├── test.pt
    │       │   └── training.pt
    │       └── raw
    │           ├── t10k-images-idx3-ubyte.gz
    │           ├── t10k-labels-idx1-ubyte.gz
    │           ├── train-images-idx3-ubyte.gz
    │           └── train-labels-idx1-ubyte.gz
    ├── models
    │   ├── resnet50-19c8e357.pth
    │   └── vgg16-397923af.pth
    ├── train_log
    │   └── W_001.pt
    ├── README.md
    ├── download.py
    ├── main.py
    ├── ....
    
    
  3. So directly run the following scripts to train the model.

    python main.py -m train -g 0 1
    

    We provide three three modes, train, validate and test. The argment -g indicates the gpu ids. Add -r 3 if you want to continue training your model from the third epoch.

Validate

Simply running the following command.

python main.py -m validate -g 0 -r 30

Results

The performance (test accuracy) of ImageNet model reprogrammed on other tasks. More experiments are welcomed by pull requests.

ImageNet Model MNIST
Resnet50 0.94
VGG16 0.94

adversarial_reprogramming's People

Contributors

prinsphield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

adversarial_reprogramming's Issues

Inquiry for performance results

Thanks for sharing this code, i got a question for the performance.

i tried to run ur main_single file and get a result of 80%. Were you using the same configuration to get 94% performance?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.