Skip to content

Commit 034b45d

Browse files
Irina NicolaeIrina Nicolae
authored andcommitted
Remove divide by 0 warning in DeepFool
(cherry picked from commit 5aaf1ed)
1 parent 51a001c commit 034b45d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

art/attacks/deepfool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def generate(self, x, **kwargs):
8181
value = np.ma.array(np.abs(f_diff) / norm, mask=mask)
8282

8383
l = value.argmin(fill_value=np.inf)
84-
r = (abs(f_diff[l]) / pow(np.linalg.norm(grad_diff[l]), 2)) * grad_diff[l]
84+
r = (abs(f_diff[l]) / (pow(np.linalg.norm(grad_diff[l]), 2) + tol)) * grad_diff[l]
8585

8686
# Add perturbation and clip result
8787
xj = np.clip(xj + r, clip_min, clip_max)

0 commit comments

Comments
 (0)