Harry24k / adversarial-attacks-pytorch

PyTorch implementation of adversarial attacks [torchattacks]
https://adversarial-attacks-pytorch.readthedocs.io/en/latest/index.html
MIT License
1.86k stars 348 forks source link

[QUESTION]The attack success rate of CW in the least-likely mode is 0, and the BIM in the same situation is above 90 #198

Open wang1528186571 opened 1 week ago

wang1528186571 commented 1 week ago

❔ Any questions

images, labels = get_imagenet_data()

print('[Data loaded]') device = "cuda" model = models.resnet50(pretrained=True).to(device).eval() acc = get_accuracy(model, [(images.to(device), labels.to(device))]) atk = torchattacks.CW(model, c=0.1, kappa=14, steps=1000, lr=0.01) atk.set_normalization_used(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) atk.set_mode_targeted_least_likely(kth_min=1)

I also noticed that there is a question about the CW success rate in the issue. He said that the data was normalized. I did that too - removed the line of code atk.set_normalization_used, but it still doesn't work.