remove stop_gradient in function optimize_linear
@@ -104,12 +104,7 @@ def optimize_linear(grad, eps, norm=np.inf):
axis = list(range(1, len(grad.get_shape())))
avoid_zero_div = 1e-12
if norm == np.inf:
- # Take sign of gradient
optimal_perturbation = tf.sign(grad)
- # The following line should not change the numerical results. It applies only because
- # `optimal_perturbation` is the output of a `sign` op, which has zero derivative anyway.
- # It should not be applied for the other norms, where the perturbation has a non-zero derivative.
- optimal_perturbation = tf.stop_gradient(optimal_perturbation)
elif norm == 1:
abs_grad = tf.abs(grad)
sign = tf.sign(grad)
