Single Pixel Attack Assertion Error
ajsanjoaquin opened this issue · comments
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)
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.
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.