Coder Social home page Coder Social logo

kathrynkai / featuresqueezing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uvasrg/featuresqueezing

0.0 1.0 0.0 20 KB

Detecting Adversarial Examples in Deep Neural Networks

Home Page: http://evademl.org/

License: MIT License

Python 100.00%

featuresqueezing's Introduction

Feature Squeezing

Detecting Adversarial Examples in Deep Neural Networks

idea_figure

Latest Updates

This repository is now obsolete.

Please move on to our EvadeML-Zoo project if you would like to conduct experiments on more datasets and models.

The old repository is preserved here, but please use https://github.com/mzweilin/EvadeML-Zoo instead of this one.

Run the code

1. Install dependencies.

pip install tensorflow==0.12.1 keras==1.2.0 pillow scikit-learn

If you are going to run experiment on GPU, you should install tensorflow-gpu instead of tensorflow.

Cleverhans v1.0.0 will be automatically fetched and located when executing from utils import load_externals in Python. You don't need to do anything on it.

2. Run the experiments on MNIST.

(Optional) Train a classification model on MNIST, then use adversarial training to get a second model.

python train_mnist_model.py

If you don't train your own models, the program python mnist_experiment.py will automatically download the pre-trained ones from our website.

First, let's test the color bit depth reduction with FGSM.

python mnist_experiment.py --task FGSM --visualize

The program will generate adversarial examples with FGSM, output a figure with image examples, and evaluate the model accuracy with and without the binary filter. In order to save time, the program only generates adversarial examples in the first run, and the later runs will reuse the adversarial examples.

Second, we will test adversarial training with and without the binary filter, so as to compare adversarial training with feature squeezing.

python mnist_experiment.py --task FGSM-adv-train

Next, we will test the median smoothing with JSMA.

python mnist_experiment.py --task JSMA --visualize

The program will generate adversarial examples with JSMA, output a figure with image examples, and evaluate the model accuracy with and without median smoothing.

Finally, we will conduct three detection experiments. The program will report the detection performance as well as the selected thresholds.

idea_figure

python mnist_experiment.py --task FGSM-detection
python mnist_experiment.py --task JSMA-detection
python mnist_experiment.py --task joint-detection

3. Review the results.

The experimental results are stored in ./results/mnist/, including tables, figures, and pickled files.

You can also download the results we generated before using one GeForce GTX 1080.

mkdir results && cd results
wget http://www.cs.virginia.edu/~wx4ed/downloads/squeezing/results_mnist.tar.gz
tar xfz results_mnist.tar.gz
rm results_mnist.tar.gz
cd ..
python mnist_experiment.py --task joint-detection

Cite this work

You are encouraged to cite the following paper if you use Feature Squeezing for academic research.

@article{xu2017feature,
  title={Feature Squeezing: Detecting Adversarial Examples in Deep Neural Networks},
  author={Xu, Weilin and Evans, David and Qi, Yanjun},
  journal={arXiv preprint arXiv:1704.01155},
  year={2017}
}

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.