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

Divide by zero #15

Closed
akshayag opened this issue Aug 29, 2018 · 5 comments
Closed

Divide by zero #15

akshayag opened this issue Aug 29, 2018 · 5 comments
Assignees
Labels
warning Warning triggered by an invalid operation

Comments

@akshayag
Copy link

Hello,

Was running the code on CIFAR for 150 epochs and with batch size 32

Craft attack on training examples
/adversarial-robustness-toolbox-master/art/attacks/deepfool.py:84: RuntimeWarning: divide by zero encountered in true_divide
r = (abs(f_diff[l]) / pow(np.linalg.norm(grad_diff[l]), 2)) * grad_diff[l]
/adversarial-robustness-toolbox-master/art/attacks/deepfool.py:84: RuntimeWarning: invalid value encountered in multiply
r = (abs(f_diff[l]) / pow(np.linalg.norm(grad_diff[l]), 2)) * grad_diff[l]

@ririnicolae
Copy link
Collaborator

Hi, @akshayag! Thanks for letting us know! I'll add a small tolerance constant to avoid divide by 0 warnings.

@ririnicolae ririnicolae self-assigned this Aug 29, 2018
@ririnicolae ririnicolae added the warning Warning triggered by an invalid operation label Aug 29, 2018
@akshayag
Copy link
Author

Please write some instructions to use other attack methods also. For example, I am getting the error when trying to run the attack CarliniL2Method

x_train_adv = adv_crafter.generate(x_train)
File "/adversarial-robustness-toolbox-master/art/attacks/carlini.py", line 124, in generate
assert not (self.targeted and y is None)
AssertionError

Similarly, if there will be an example line for other methods also to craft the adversary.

@ririnicolae
Copy link
Collaborator

We will try to provide more examples. Meanwhile, for your current error, as per CarliniL2Method documentation, you either need to set targeted=False when creating the attack, or provide target labels y when calling generate.

@akshayag
Copy link
Author

Please take a look at this error also.

Create VirtualAdversarialMethod attack

Craft attack on training examples
/adversarial-robustness-toolbox-master/art/attacks/virtual_adversarial.py:91: RuntimeWarning: invalid value encountered in float_scalars
d_new[array_iter.multi_index] = (kl_div2 - kl_div1) / self.finite_diff
/adversarial-robustness-toolbox-master/art/attacks/virtual_adversarial.py:116: RuntimeWarning: invalid value encountered in multiply
x = x * inverse

@ririnicolae
Copy link
Collaborator

@akshayag Fix for both divide by 0 issues is pushed. Please confirm that the warning is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
warning Warning triggered by an invalid operation
Projects
None yet
Development

No branches or pull requests

2 participants