cleverhans-lab / cleverhans

An adversarial example library for constructing attacks, building defenses, and benchmarking both
MIT License
6.21k stars 1.39k forks source link

jsma method pertubated the same feature(first feature) iteratively untile , while all elements in "scores_mask" are 0s. #221

Closed scml closed 7 years ago

scml commented 7 years ago

While I implemented jsma method with my data, I saw the perturbation features are all the same shown bleow.

print chosen feature every iteration. I thought it caused by all elements in scores_mask are 0s.

scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0 nf 140 scores_mask.shape: (140, 140) Best: 0 p1: 0 p2: 0

npapernot commented 7 years ago

Could you be a more specific? It's hard to understand what your problem is based on the information you shared.

Perhaps the gradients of your model are all nan?

scml commented 7 years ago

Sorry for the unclear description. What I encountered is I found some samples weren't perturbated well when I used JSMA method. I set the distortion rate as 25%. As I have 140 input features, it should iterate 17 times( assigned 34 features) in JSMA(def jsma) as it didn't cheat the classifier(FCNN). I thought my average distortion rate would reach some point more than 4%, which is the average distortion rate I got.

I dived into the code and printed each input features Saliency Map(def saliency_map) chose. Somehow in some samples, NOT all samples, Saliency Map(def saliency_map) chose the same point, the first point(feature of index 0), all the time. While I printed the score mask(140*140), all the elements in score mask were 0s which means no derivate met the condition ((target_sum > 0) & (other_sum < 0)). I am not sure it meant to be like that or not. I am pretty sure my gradients are not all nan. I excluded the situation since I have trained a CNN with embedding layer which caused the gradients all nan in my previous experiment.

Hope it helps. If it is not clear enough, I'd like to provide my model and dataset. Really appreciate your work~

npapernot commented 7 years ago

Again, it is hard to debug your problem without access to the code or a more isolated description of what part of the experiment is failing. Have you tried checking the result of jacobian()?

npapernot commented 7 years ago

I am about to close this, unless you are able to share more information to help us understand where the problem comes from.