format into black
format the code into black using pip installed package.
@@ -19,7 +19,7 @@ def momentum_iterative_method(
y=None,
targeted=False,
decay_factor=1.0,
- sanity_checks=True
+ sanity_checks=True,
):
"""
Tensorflow 2.0 implementation of Momentum Iterative Method (Dong et al. 2017).
@@ -90,7 +90,8 @@ def momentum_iterative_method(
avoid_zero_div = tf.cast(1e-12, grad.dtype)
grad = grad / tf.math.maximum(
avoid_zero_div,
- tf.math.reduce_mean(tf.math.abs(grad), red_ind, keepdims=True))
+ tf.math.reduce_mean(tf.math.abs(grad), red_ind, keepdims=True),
+ )
momentum = decay_factor * momentum + grad
optimal_perturbation = optimize_linear(momentum, eps_iter, norm)
@@ -107,10 +108,8 @@ def momentum_iterative_method(
return adv_x
-def loss_fn(
- labels,
- logits
-):
+
+def loss_fn(labels, logits):
"""
Added softmax cross entropy loss for MIM as in the original MI-FGSM paper.
"""
