Jeffkang-94 / pytorch-adversarial-attack

Implementation of gradient-based adversarial attack(FGSM,MI-FGSM,PGD)
77 stars 10 forks source link

Error in mifgsm.py ? #2

Open HuangZuShu opened 2 years ago

HuangZuShu commented 2 years ago

https://github.com/Jeffkang-94/pytorch-adversarial-attack/blob/3b5877b3fd30524ccf9318e005b5b6cef3453652/attack/mifgsm.py#L32 The right code should be as following:

if self.target is None:
    cost = -F.cross_entropy(logit, y)
else:
    cost = F.cross_entropy(logit, self.target)