Code Monkey home page Code Monkey logo

magnet's Introduction

MagNet

Demo code for "MagNet: a Two-Pronged Defense against Adversarial Examples", by Dongyu Meng and Hao Chen, at CCS 2017.

The code demos black-box defense against Carlini's L2 attack of various confidences. Other techniques proposed in the paper are also included in defensive_models.py and worker.py, but are not shown in the demo defense. Attack implementations are not provided in this repository.

Run the demo code:

  1. Make sure you have Keras, Tensorflow, numpy, scipy, and matplotlib installed.
  2. Clone the repository.
  3. We provide demo attack data and classifier on Dropbox and 百度网盘 (密码: yzt4). Please download and put the unzipped files in MagNet/. You may also use your own data for test.
  4. Train autoencoders with python3 train_defense.py.
  5. Test the defense with python3 test_defense.py .
  6. Defense performance is plotted in graph/defense_performance.pdf.

magnet's People

Contributors

trevillie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

magnet's Issues

Implementation of the CIFAR10 autoencoder

Hi, we didn't try our old model but we can get a even better result with the following structure:
input -> 3x3x32 conv -> BN -> Relu -> 3x3x32 conv -> Relu ->BN -> 3x3x3 conv -> output

BTW, since we don't have our old classifier, we used a DenseNet classifier with acc ~92%.

1453107770

Hope this helps.

Originally posted by @Trevillie in #2 (comment)

In your response to issue #2, you suggest using an even better structure: input -> 3x3x32 conv -> BN -> Relu -> 3x3x32 conv -> Relu ->BN -> 3x3x3 conv -> output.

But when I implement this structure for CIFAR10 Detector or Reformer, I found it happens to errors because it cannot make the output in the range of [0, 1].
Is that structure really work in your experiments? how do you do to make it work in your experiments?

inconsistent l_p value used in detector

In the original paper section 5.2.1, the paper said

Detector II and detector I(see Table 3) used the $L^2$ and $L^1$ norm to measure reconstruction error, respectively.

However, in the following implementation, you use L1 for detector II and L2 for detector I.

detector_I = AEDetector("./defensive_models/MNIST_I", p=2)

detector_II = AEDetector("./defensive_models/MNIST_II", p=1)

I am asking is this a just typo? Can you confirm which one should be the correct one.

It seems the code in the repo gives the better result.

Implementation of the CIFAR autoencoder/reformer

Hi I've been trying to reproduce your CIFAR results for a couple of weeks now, but after following the architecture in your paper, I've only gotten ~40% accuracy with detector and reformer. Would it be possible to upload your implementation of the CIFAR MagNet architecture? Thank you

how to change adversarial samples

Hi,I know the demo is for C&W adversarial attack,now I need to test other adversarial samples,Could you tell me how to make it in a easy way.Thank you!

Inconsistency with your results of Figure 4&5 in the paper

Hi! I'm trying to reproduce your results of defense performance with different confidence of Carlini’s L2 attack on MNIST & CIFAR10 (Figure 4&5). But I met some issues.
For MNIST:
I generated about 10000 adversarial samples for each confidence(0.0, 10.0, 20.0, 30.0, 40.0). For total about 50000 samples. I got the following graph.
defense_performance_mnist
My no_defense curve has a downward trend with a high accuracy at confidence of 0.0. But your no_defense accuracy keeps 0% at any confidence. Since higher confidence yields higher attack success rate, I wonder why you got such a curve.
For CIFAR10:
I generated about 10000 adversarial samples for each confidence(0.0, 20.0, 40.0, 60.0, 80.0, 100.0). For total about 60000 samples. I got the following graph.
defense_performance_cifar
Besides the no_defense issue in MNIST, my with_detector curve is also inconsistent with yours. Your curve in the paper shows a upward trend. And my test data shows that nearly 99% of the adversarial samples pass the detector. The detector seems not to work.
I've seen your talk in ISSUE 1. So I also used your new autoencoder architecture and a better classifier with an accuracy of 86%. I got the following graph.
defense_performance_cifar_better
The trends of curves seem not to change. Only a higher beginning accuracy was acquired.
To sum up, there are 2 issues:

  1. My no_defense curve is inconsistent with yours.
  2. The detector seems not to make any difference in my experiment.
    Could you help me deal with the problem? Thank you very much!

my result is not as good as yours in P10 figure4

Hi! I have implemented your results of defense in MNIST dataset, but the results is not as good as yours.
I have trained the defense model and the classify model, and download the data which you upload to the Baiduyun , and test the defense performance . My classify model accuracy is 99%+, and the mean_squared_error of two autoencoder model is less than 0.003. Finally,I got the following graph.
2efekgxy ple90 u qo v x

I think there may be a problem with the detector,but I dont known the reason!

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.