Code Monkey home page Code Monkey logo

defensegan-and-cowboy-defense's Introduction

DefenseGAN-and-Cowboy-Defense

This repository implements the two popular defense architectures DefenseGAN and Cowboy that leverage GAN to protect classifiers against test time evasive adversarial attacks

Both of these defense architectures require trained Generator and Discriminator on clean dataset, hence we train a GAN on MNIST dataset.

models.py implements the GAN models in pytorch and directly follows the implementation of the DCgan paper https://arxiv.org/abs/1511.06434.

dc_gan.py takes these models defined in models.py and trains a GAN from scratch in pytorch lightning. The Gan training has been stabilized by employing some of the tricks from the popular repository https://github.com/soumith/ganhacks.

  • 1: BatchNorm
  • 2: Label Smoothing
  • 3 : Adding Noise to the inputs of the Discrimnator

The above hacks helped a lot in stabilizing gan training, earlier while training the gan, the discriminator loss became 0 in very few number of epochs which is a red flag because it meant the discriminator had learnt very quickly and subsequent training would not help the generator very much to improve.

The below image shows the gan training when it was unstable here we can see clearly that the discriminator loss is becoming very small in about 100 epochs.

Alt Text


The below images shows the gan training after using the stabilizing techniques, it also compares the loss curves with the previous unstable training, here we can observe that discriminator loss is less steeper than before, this results in better quality of trained generator.
Alt Text


The file defense.py implements the DefenseGAN and cowboy defense architectures.
DefenseGAN requires the trained generator to project the adversarial image to the manifold learnt by the generator. This can help in removing the perturbations, for more theoretical insight refer to my presentation in this repository or the paper https://arxiv.org/abs/1805.06605

Alt Text

Cowboy Defense on the other hand uses both the trained generator and the trained discriminator for constructing a defense architecture. The code follows the paper https://arxiv.org/abs/1805.10652

defensegan-and-cowboy-defense's People

Contributors

mnswdhw 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.