Skip to content

Commit 40c96d8

Browse files
Irina NicolaeIrina Nicolae
authored andcommitted
Correct test against None values for clipping
1 parent f2fb60f commit 40c96d8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/attacks/fast_gradient.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ def set_params(self, **kwargs):
211211
if self.ord not in [np.inf, int(1), int(2)]:
212212
raise ValueError("Norm order must be either np.inf, 1, or 2.")
213213

214-
if self.eps <= self.clip_min or self.eps > self.clip_max:
215-
raise ValueError('The amount of perturbation has to be in the data range.')
214+
if self.clip_min is not None and self.clip_max is not None:
215+
if self.eps <= self.clip_min or self.eps > self.clip_max:
216+
raise ValueError('The amount of perturbation has to be in the data range.')
216217

217218
return True

0 commit comments

Comments
 (0)