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

Is this method relevant for binary classification? #1

Open
leleogere opened this issue Nov 7, 2022 · 3 comments
Open

Is this method relevant for binary classification? #1

leleogere opened this issue Nov 7, 2022 · 3 comments

Comments

@leleogere
Copy link

leleogere commented Nov 7, 2022

Those adversarial gradients seem quite promising to get rid of this arbitrary baseline.

However, in the case of binary classification, would this method be relevant? There would be only one adversarial example, not multiple ones like in a multi-class problem. What are your thoughts about that?

@leleogere leleogere changed the title Is this method suited for binary classification? Is this method relevant for binary classification? Nov 7, 2022
@pd90506
Copy link
Owner

pd90506 commented Dec 9, 2022

This method is not specified to multi-class problems. In a binary case, there will be only 1 adversarial class, which leads this method to a form similar to IG, except that IG requires a straightline path and a starting reference point, this AGI method is still able to automatically find a path.

@leleogere
Copy link
Author

Thank you for your answer, that is what I thought but I wasn't sure.

Anyway thank you for your work, I managed to get some pretty amazing results with this method that I could not get with classical IG.

One last question, is it normal that on the following lines the delta is not normalized?

AGI/AGI_main.py

Lines 89 to 90 in 4b28c8b

grad_lab_norm = torch.norm(data_grad_lab,p=2)
delta = epsilon * data_grad_adv.sign()

According to the algorithm below, I would expect something like delta = epsilon * (data_grad_adv / grad_lab_norm).sign() (especially as it seems that the variable grad_lab_norm is not used anywhere).

algorithm

There could be an issue when the gradient is zero, but it could be solved by clipping the norm to some small value:

delta = epsilon * (data_grad_adv / torch.clamp(grad_lab_norm, min=1e-8)).sign()

@pd90506
Copy link
Owner

pd90506 commented Apr 2, 2024

Thank you for your answer, that is what I thought but I wasn't sure.

Anyway thank you for your work, I managed to get some pretty amazing results with this method that I could not get with classical IG.

One last question, is it normal that on the following lines the delta is not normalized?

AGI/AGI_main.py

Lines 89 to 90 in 4b28c8b

grad_lab_norm = torch.norm(data_grad_lab,p=2)
delta = epsilon * data_grad_adv.sign()

According to the algorithm below, I would expect something like delta = epsilon * (data_grad_adv / grad_lab_norm).sign() (especially as it seems that the variable grad_lab_norm is not used anywhere).

algorithm

There could be an issue when the gradient is zero, but it could be solved by clipping the norm to some small value:

delta = epsilon * (data_grad_adv / torch.clamp(grad_lab_norm, min=1e-8)).sign()

Yes! You're correct. But since we only take the sign, it shouldn't cause any differences. Your suggestion should also work.

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