code: def deepfool(x, loss=None, bounds=(0, 1)):
      (clip_min, clip_max) = bounds
  
      (grad,) = tf.gradients(loss, x)
  
      r = old_div(grad * loss, tf.reduce_sum(tf.square(grad)))
  
      # 目标是让loss下降
      adv_x = x - r
  
      if (clip_min is not None) and (clip_max is not None):
          adv_x = tf.clip_by_value(adv_x, clip_min, clip_max)
  
      return adv_x
  
file_path: AdvBox/adversarialbox/attacks/tf/tools.py
imports: from __future__ import division
  from builtins import range
  from past.utils import old_div
  import logging
  import numpy
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: deepfool(x, loss, bounds) and returns: adv_x