code: def main(_):
      """Run the sample attack"""
      # Images for inception classifier are normalized to be in [-1, 1] interval,
      # eps is a difference between pixels so it should be in [0, 2] interval.
      # Renormalizing epsilon from [0, 255] to [0, 2].
      eps = 2.0 * FLAGS.max_epsilon / 255.0
      batch_shape = [
          FLAGS.batch_size,
          FLAGS.image_height,
          FLAGS.image_width,
          3,
      ]
      nb_classes = 1001
  
      tf.logging.set_verbosity(tf.logging.INFO)
  
      with tf.Graph().as_default():
          # Prepare graph
          x_input = tf.placeholder(tf.float32, shape=batch_shape)
  
          model = InceptionModel(nb_classes)
  
          fgsm = FastGradientMethod(model)
          x_adv = fgsm.generate(
              x_input, eps=eps, clip_min=-1.0, clip_max=1.0
          )
  
          # Run computation
          saver = tf.train.Saver(slim.get_model_variables())
          session_creator = tf.train.ChiefSessionCreator(
              scaffold=tf.train.Scaffold(saver=saver),
              checkpoint_filename_with_path=FLAGS.checkpoint_path,
              master=FLAGS.master,
          )
  
          with tf.train.MonitoredSession(
              session_creator=session_creator
          ) as sess:
              for filenames, images in load_images(
                  FLAGS.input_dir, batch_shape
              ):
                  adv_images = sess.run(
                      x_adv, feed_dict={x_input: images}
                  )
                  save_images(adv_images, filenames, FLAGS.output_dir)
  
file_path: cleverhans/cleverhans_v3.1.0/examples/nips17_adversarial_competition/dev_toolkit/sample_attacks/fgsm/attack_fgsm.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import warnings
  import numpy
  import tensorflow
  from tensorflow.contrib.slim.nets import inception
  from PIL import Image
  from cleverhans.attacks import FastGradientMethod
label_desc: Use image node_id 3 for calling a global function with example usage: main(_) without return types