Harry24k/adversarial-attacks-pytorch

[QUESTION]The 'inf' in 'deepfool.py'

Closed this issue · 2 comments

❔ Any questions

Dear author, I was using the DeepFool method for my classification task. But I have been getting this error(using CPU) :

Traceback (most recent call last):
  File "train.py", line 198, in <module>
    main()
  File "train.py", line 195, in main
    train(args.fold)
  File "train.py", line 162, in train
    generate_attack_data(net,train_dataloader,fold,config.data_config)
  File "/root/workspace/SDAANet/attack.py", line 16, in generate_attack_data
    adv_images = attack(images, labels)
  File "/root/miniconda3/lib/python3.8/site-packages/torchattacks/attack.py", line 452, in __call__
    adv_inputs = self.forward(inputs, labels, *args, **kwargs)
  File "/root/miniconda3/lib/python3.8/site-packages/torchattacks/attacks/deepfool.py", line 57, in forward
    early_stop, pre, adv_image = self._forward_indiv(adv_images[idx], labels[idx])
  File "/root/miniconda3/lib/python3.8/site-packages/torchattacks/attacks/deepfool.py", line 92, in _forward_indiv
    value[label] = float('inf')
IndexError: index 1 is out of bounds for dimension 0 with size 1

I found that value[label] = float('inf') doesn't show in the github repositories but in the v3.4.0. I think it is a bug, isn't it?

Hi @songty21110133, this is a bug, please reinstall torchattacks from source. 😜

thank you very much!