Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Pixel Attack Assertion Error #68

Closed
ajsanjoaquin opened this issue Feb 2, 2021 · 2 comments
Closed

Single Pixel Attack Assertion Error #68

ajsanjoaquin opened this issue Feb 2, 2021 · 2 comments

Comments

@ajsanjoaquin
Copy link

I get an Assertion Error when trying to run the Single Pixel Attack. Apparently, axes length must be equal to 2 (H, W), but my axes length is equal to 3 (B, H, W). I tried squeezing my img_tensor (3, 244, 244) but the predict method breaks. I tried removing the Assertion statement but creates an Index error.

Can anyone tell me how to properly use the Single Pixel Attack? I followed the same method as shown in the FGSM notebook example written in Pytorch.

Code to reproduce:

from adversarialbox.attacks.localsearch import SinglePixelAttack

# initialize model and img_tensor here

attack = SinglePixelAttack(model)  # Channel axis = 1
adversary = Adversary(img_tensor.to('cpu'), label)  # Tensor shape: (1, 3, 244, 244) B, C, H, W

adversary = attack(adversary)
@jayxio
Copy link
Contributor

jayxio commented Feb 3, 2021

Could you try using MNIST dataset to run the Single Pixel Attack tutorial in tutorials? Single Pixel Attack is a demo intended for the MNIST dataset. The diversity of different datasets preprocessing limits the versatility.

@ajsanjoaquin
Copy link
Author

Yes, it works for MNIST. Thanks. Although it would be good if there was a note in the attacks README that states which attacks are currently demos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants