Giter Club home page Giter Club logo

stadv's Introduction

stAdv: Spatially Transformed Adversarial Examples with TensorFlow

Deep neural networks have been shown to be vulnerable to adversarial examples: very small perturbations of the input having a dramatic impact on the predictions. In this package, we provide a TensorFlow implementation for a new type of adversarial attack based on local geometric transformations: Spatially Transformed Adversarial Examples (stAdv).

illustration-stadv-mnist.png

Our implementation follows the procedure from the original paper:

Spatially Transformed Adversarial Examples
Chaowei Xiao, Jun-Yan Zhu, Bo Li, Warren He, Mingyan Liu, Dawn Song

If you use this code, please cite the following paper for which this implementation was originally made:

Robustness of Rotation-Equivariant Networks to Adversarial Perturbations
Beranger Dumont, Simona Maggio, Pablo Montalvo

Installation

First, make sure you have installed TensorFlow (CPU or GPU version).

Then, to install the stadv package, simply run

$ pip install stadv

Usage

A typical use of this package is as follows:

  1. Start with a trained network implemented in TensorFlow.
  2. Insert the stadv.layers.flow_st layer in the graph immediately after the input layer. This is in order to perturb the input images according to local differentiable geometric perturbations parameterized with input flow tensors.
  3. In the end of the graph, after computing the logits, insert the computation of an adversarial loss (to fool the network) and of a flow loss (to enforce local smoothness), e.g. using stadv.losses.adv_loss and stadv.losses.flow_loss, respectively. Define the final loss to be optimized as a combination of the two.
  4. Find the flows which minimize this loss, e.g. by using an L-BFGS-B optimizer as conveniently provided in stadv.optimization.lbfgs.

An end-to-end example use of the library is provided in the notebook demo/simple_mnist.ipynb (see on GitHub).

Documentation

The documentation of the API is available at http://stadv.readthedocs.io/en/latest/stadv.html.

Testing

You can run all unit tests with

$ make init
$ make test

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.