Add tests against invalid arguments for FGM
@@ -28,7 +28,14 @@ def fast_gradient_method(model_fn, x, eps, ord,
:return: a tensor for the adversarial example
"""
if ord not in [np.inf, 1, 2]:
- raise ValueError("Norm order must be either np.inf, 1, or 2.")
+ raise ValueError("Norm order must be either np.inf, 1, or 2, got {} instead.".format(ord))
+ assert eps >= 0, "eps must be greater than or equal to 0, got {} instead".format(eps)
+ if eps == 0:
+ return x
+ if clip_min is not None and clip_max is not None:
+ assert clip_min <= clip_max, \
+ "clip_min must be less than or equal to clip_max, got clip_min={} and clip_max={}".format(
+ clip_min, clip_max)
asserts = []
