switch JSMA jacobian computation from probs to logits
@@ -12,7 +12,6 @@ from cleverhans.compat import reduce_sum, reduce_max, reduce_any
tf_dtype = tf.as_dtype('float32')
-
class SaliencyMapMethod(Attack):
"""
The Jacobian-based Saliency Map Method (Papernot et al. 2016).
@@ -192,9 +191,10 @@ def jsma_symbolic(x, y_target, model, theta, gamma, clip_min, clip_max):
preds_onehot = tf.one_hot(tf.argmax(preds, axis=1), depth=nb_classes)
# create the Jacobian graph
+ logits = model.get_logits(x_in)
list_derivatives = []
for class_ind in xrange(nb_classes):
- derivatives = tf.gradients(preds[:, class_ind], x_in)
+ derivatives = tf.gradients(logits[:, class_ind], x_in)
list_derivatives.append(derivatives[0])
grads = tf.reshape(
tf.stack(list_derivatives), shape=[nb_classes, -1, nb_features])
