Skip to content

Commit

Permalink
cast to tensor if in numpy array for fgsm attack
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamannett committed Mar 30, 2021
1 parent 1233a4a commit e719317
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cleverhans/tf2/attacks/fast_gradient_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def fast_gradient_method(
if clip_max is not None:
asserts.append(tf.math.less_equal(x, clip_max))

# cast to tensor if provided as numpy array
x = tf.cast(x, tf.float32)

if y is None:
# Using model predictions as ground truth to avoid label leaking
y = tf.argmax(model_fn(x), 1)
Expand Down

0 comments on commit e719317

Please sign in to comment.