When I try to use FGSM,there is an error occured:
AttributeError Traceback (most recent call last)
in
57 ############### FGSM ################################
58 fgsm = FGSM(model,criterion,img_tsor,label,epsilon)
---> 59 fg_adv_img,fg_perturbation = fgsm.attack()
60
61 fg_output_adv,fg_pred_adv, fg_op_adv_probs, fg_adv_pred_prob = getPredictionInfo(model,fg_adv_img)
D:\Graduate\attacks_with_pytorch\adversarial-attacks-pytorch-master\FGSM.py in attack(self)
32 # print(loss)
33 loss.backward()
---> 34 img_grad = torch.sign(self.orig_img.grad.data) # sign of the gradient
35 adv_img = self.orig_img.data + self.epsilon*img_grad
36 # output_adv = self.model(torch.tensor(adv_img))
AttributeError: 'NoneType' object has no attribute 'data'
Do you know how to solve it?thanks a lot!