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

A question about MI-FGSM #2

Closed
chenchenczy opened this issue Sep 20, 2024 · 1 comment
Closed

A question about MI-FGSM #2

chenchenczy opened this issue Sep 20, 2024 · 1 comment

Comments

@chenchenczy
Copy link

I found that when running the MI-FGSM code, the final accuracy is independent of the decay_factor parameter, which leads to the results of MI-FGSM and I-FGSM always being the same. How can this issue be resolved?Is there a problem with the implementation of the code? I set epsilon=0.1, iters=10, and alpha=1.

@gralliry
Copy link
Owner

Thank for your issue!
There may be something wrong in mi_fgsm.py
You can view (https://github.com/dongyp13/Non-Targeted-Adversarial-Attacks/blob/master/attack_iter.py) line 184

# attack/mi_fgsm.py line60
                ...
                grad = pert_image.grad.sign()
                grad = self.decay_factor * grad + grad / torch.norm(grad, p=1)
                pert_image = pert_image + alpha * torch.sign(grad)

Change to the following code:

                ...
                grad = pert_image.grad
                grad = self.decay_factor * grad + grad / torch.norm(grad, p=1)
                pert_image = pert_image + alpha * torch.sign(grad)

I haven't tried this modification yet to prove if it's correct, you can try it.
Have a good code

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