Harry24k / adversarial-attacks-pytorch

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

[QUESTION] It's time to release a new version of torchattack #118

Closed rikonaka closed 1 year ago

rikonaka commented 1 year ago

❔ Any questions

I got an error when using cw attack, I know the bug has been fixed but the problem still exists in the pip package (version 3.3.0), time to release a new version of torchattack 😀.

  File "/home/hero/exp-code/0_attack.py", line 125, in test
    adv_inputs = attack(inputs, targets)
  File "/home/hero/.local/lib/python3.9/site-packages/torchattacks/attack.py", line 429, in __call__
    adv_inputs = self.forward(inputs, labels, *args, **kwargs)
  File "/home/hero/.local/lib/python3.9/site-packages/torchattacks/attacks/cw.py", line 84, in forward
    f_loss = self.f(outputs, labels).sum()
  File "/home/hero/.local/lib/python3.9/site-packages/torchattacks/attacks/cw.py", line 125, in f
    one_hot_labels = torch.eye(len(outputs[0]))[labels].to(self.device)
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)