Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ragarding the attacking mode in Class Attack. #14

Closed
tao-bai opened this issue Dec 13, 2020 · 2 comments
Closed

Ragarding the attacking mode in Class Attack. #14

tao-bai opened this issue Dec 13, 2020 · 2 comments

Comments

@tao-bai
Copy link
Contributor

tao-bai commented Dec 13, 2020

Hi Harry, I see the below codes and feel a little confused.
When performing untargeted attacks, self._targeted = 1

cost = self._targeted*loss(outputs, labels)
grad = torch.autograd.grad(cost, images,retain_graph=False, create_graph=False)[0]
adv_images = images + self.eps*grad.sign()

Is it easier to understand to set self._targeted = -1 for untargeted attacks?
and modify corresponding lines

cost = self._targeted*loss(outputs, labels)
grad = torch.autograd.grad(cost, images,retain_graph=False, create_graph=False)[0]
adv_images = images - self.eps*grad.sign()
@Harry24k
Copy link
Owner

Thank you for your suggestion.
It seems to have been implemented in that way in order not to change much of the existing code when adding the targeted mode.
I think it would be better to change it.

@Harry24k
Copy link
Owner

Harry24k commented Jan 4, 2021

Updated!

80e3741

@Harry24k Harry24k closed this as completed Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants