Giter VIP home page Giter VIP logo

Comments (2)

carlini avatar carlini commented on September 15, 2024

There are two types of attacks:

  1. Maximize adversarialness subject to the distortion being less than some threshold.
  2. Minimize distortion subject to the image being adversarial.

This attack is of the second flavor. So you can't directly control how many pixels are perturbed, it will keep shrinking the number of pixels until it can't succeed any more.

The simplest thing to do is just to run the attack and then at the end check if the number of pixels that changed is less than your threshold. If yes, the attack succeeded. Slightly more efficient would be to add an extra check around here
https://github.com/carlini/nn_robust_attacks/blob/master/l0_attack.py#L228
That will break out of the loop if equal_count > threshold.

from nn_robust_attacks.

lith0613 avatar lith0613 commented on September 15, 2024

There are two types of attacks:

  1. Maximize adversarialness subject to the distortion being less than some threshold.
  2. Minimize distortion subject to the image being adversarial.

This attack is of the second flavor. So you can't directly control how many pixels are perturbed, it will keep shrinking the number of pixels until it can't succeed any more.

The simplest thing to do is just to run the attack and then at the end check if the number of pixels that changed is less than your threshold. If yes, the attack succeeded. Slightly more efficient would be to add an extra check around here
https://github.com/carlini/nn_robust_attacks/blob/master/l0_attack.py#L228
That will break out of the loop if equal_count > threshold.

Yes, I have tried this method as your instruction and the result is okay!

equal_count = self.image_size**2-np.sum(np.all(np.abs(img-nimg[0])<.0001,axis=2)) 
if equal_count <threshold:
      return last_solution

Thanks so much !

from nn_robust_attacks.

Related Issues (20)

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.