Skip to content

Commit

Permalink
Merge pull request cleverhans-lab#1206 from grahamannett/master
Browse files Browse the repository at this point in the history
cast to tensor if in numpy array for fgsm attack
  • Loading branch information
alkaet authored Mar 31, 2021
2 parents 1233a4a + e719317 commit cb5a1bf
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 cb5a1bf

Please sign in to comment.