GithubHelp home page GithubHelp logo

ykankaya / one-pixel-attack-keras Goto Github PK

View Code? Open in Web Editor NEW

This project forked from neuroradiology/one-pixel-attack-keras

0.0 1.0 0.0 154.01 MB

Keras reimplementation of "One pixel attack for fooling deep neural networks" using differential evolution on cifar10

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

License: MIT License

Python 21.46% Jupyter Notebook 78.54%

one-pixel-attack-keras's Introduction

One Pixel Attack

Who would win?

How simple is it to cause a deep neural network to misclassify an image if we are only allowed to modify the color of one pixel and only see the prediction probability? Turns out it is very simple. In many cases, we can even cause the network to return any answer we want.

The following project is a Keras reimplementation and tutorial of "One pixel attack for fooling deep neural networks".

How It Works

For this attack, we will use the Cifar10 dataset. The task of the dataset is to correctly classify a 32x32 pixel image in 1 of 10 categories (e.g., bird, deer, truck). The black-box attack requires only the probability labels (the probability value for each category) that get outputted by the neural network. We generate adversarial images by selecting a pixel and modifying it to a certain color.

By using an Evolutionary Algorithm called Differential Evolution (DE), we can iteratively generate adversarial images to try to minimize the confidence (probability) of the neural network's classification.

Ackley GIF

First, generate several adversarial samples that modify a random pixel and run the images through the neural network. Next, combine the previous pixels' positions and colors together, generate several more adversarial samples from them, and run the new images through the neural network. If there were pixels that lowered the confidence of the network from the last step, replace them as the current best known solutions. Repeat these steps for a few iterations; then on the last step return the adversarial image that reduced the network's confidence the most. If successful, the confidence would be reduced so much that a new (incorrect) category now has the highest classification confidence.

See below for some examples of successful attacks:

Examples

Getting Started

A dedicated GPU suitable for running with Keras is recommended to run the tutorial. Alternatively, you can view the tutorial notebook on GitHub.

  1. Install the python packages in requirements.txt if you don't have them already.
pip install -r ./requirements.txt
  1. Clone the repository.
git clone https://github.com/Hyperparticle/one-pixel-attack
cd ./one-pixel-attack
  1. Run the iPython tutorial notebook with Jupyter.
jupyter notebook ./one-pixel-attack.ipynb

Training and Testing

TODO: need to implement a CLI!

Milestones

  • Cifar10 dataset
  • Tutorial notebook
  • Lecun Network, Network in Network, Residual Network, DenseNet models
  • Configurable command-line interface
  • Efficient differential evolution implementation
  • MNIST dataset
  • ImageNet dataset
  • Test on Capsule Networks

one-pixel-attack-keras's People

Contributors

hyperparticle avatar

Watchers

 avatar

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.