Giter VIP home page Giter VIP logo

advattack's Introduction

AdvAttack

Zeroth Order Optimization Based Black-box Attacks to Deep Neural Networks

This repository contains the code to implements various zero order algorithms used to perform adversarial attacks against black box Deep Neural Networks.
The full description of the problem, analysis and conclusion can be found in Report.pdf.

Requirements

  • Python 3
  • sys
  • os
  • time
  • argparse
  • warnings
  • json
  • datatime
  • tqdm
  • numpy
  • matplotlib
  • PIL
  • sklearn
  • torch
  • torchvision

Code Structure

  • papers
  • models
  • results
    • [optimizer]
    • Summary Results.ipynb
  • scripts
    • test.py
    • evaluation.py
  • src
    • dataset.py
    • models.py
    • train.py
    • loss.py
    • ZOOptim.py
    • zeroOptim.py
    • FWOptim.py
  • Attack[dataset]_[optimizer].py
  • TransferLearning.ipynb
  • Report.pdf

Description

Papers contains the 4 papers used as references in this project.

Models contains the three models used and their weights: VGG16, InceptionV3 and an ad-hoc network.

Results contains one sub-folder for each Optimizer, each one containing the csv file related to the evaluation of the specified optimizer. It also contains a jupyter notebook used to generate the plots presented in the report.

Scripts contains two python files: test.py is used to perform an attack to a single image with the specified Optimizer, evaluation.py does the same on a batch of images.

Src contains:

  • dataset.py is used to retrieve MNIST and CIFAR, to display some informations and eventually to rescale them to be compatible with InceptionV3.
  • models.py is used to retrieve or create the three networks used (VGG16, InceptionV3 and an Ad-Hoc Network), to train and evaluate them.
  • train.py is used to train the networks.
  • loss.py implements the two loss functions used (Mean Squared Erorr and ZOO Loss).
  • [XXX]Optim.py implement the optimizers described in the papers.

Attack[dataset]_[optimizer].py are used to perform a specific attack on a specific dataset and to visualize the generated adversarial image and the loss function.

Examples

Here we give an example of how to run an evaluation of Zero Stochastic Conditional Gradient with Inexact Updates against VGG16 fine-tuned on Cifar10. Only a subset of arguments will be given, full explanation of the arguments can be found inside the scripts.
If the data is not already present in the folder data the scripts will automatically create the folder data and download the data in there.

  cd scripts
  evaluation.py --optimizer "inexact" -- data "cifar10" --maximise 0 --epochs 100 --n_gradient 4000 --batch_size 1000 --mu 0.0025 --gamma 1       

N.B
1- All the scripts and jupyter notebook should be able to run without a problem in GPU thanks to cuda interface. If you don't have cuda or you are not able to have it (you don't have an NVIDIA GPU), we strongly suggest you to run everything on Google Colab.

2- The models uploaded are only VGG16 and MNISTNet while the InceptionV3 fine-tuned on Cifar10 and MNIST data are not present. To fine -tune your InceptionV3 model you can see TransferLearning.ipynb or you can contact us at [email protected] and we will send you the model through Google Drive.

advattack's People

Contributors

f-grimaldi avatar paolofantuz avatar domsoli avatar damiclem 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.