Get logits when the input is perturbed in an interval in adv direction.

  Args:
      sess: Tf session
      model: Model for which we wish to get logits.
      x_data: Numpy array corresponding to single data.
              point of shape [height, width, channels].
      fgsm_params: Parameters for generating adversarial examples.
      min_epsilon: Minimum value of epsilon over the interval.
      max_epsilon: Maximum value of epsilon over the interval.
      num_points: Number of points used to interpolate.

  Returns:
      Numpy array containing logits.

  Raises:
      ValueError if min_epsilon is larger than max_epsilon.

def get_logits_over_interval(sess, model, x_data, fgsm_params,
                             min_epsilon=-10., max_epsilon=10.,
                             num_points=21):
  """Get logits when the input is perturbed in an interval in adv direction.

  Args:
      sess: Tf session
      model: Model for which we wish to get logits.
      x_data: Numpy array corresponding to single data.
              point of shape [height, width, channels].
      fgsm_params: Parameters for generating adversarial examples.
      min_epsilon: Minimum value of epsilon over the interval.
      max_epsilon: Maximum value of epsilon over the interval.
      num_points: Number of points used to interpolate.

  Returns:
      Numpy array containing logits.

  Raises:
      ValueError if min_epsilon is larger than max_epsilon.
  """
  # Get the height, width and number of channels
  height = x_data.shape[0]
  width = x_data.shape[1]
  channels = x_data.shape[2]

  x_data = np.expand_dims(x_data, axis=0)
  import tensorflow as tf
  from cleverhans.attacks import FastGradientMethod

  # Define the data placeholder
  x = tf.placeholder(dtype=tf.float32,
                     shape=[1, height,
                            width,
                            channels],
                     name='x')
  # Define adv_x
  fgsm = FastGradientMethod(model, sess=sess)
  adv_x = fgsm.generate(x, **fgsm_params)

  if min_epsilon > max_epsilon:
    raise ValueError('Minimum epsilon is less than maximum epsilon')

  eta = tf.nn.l2_normalize(adv_x - x, dim=0)
  epsilon = tf.reshape(tf.lin_space(float(min_epsilon),
                                    float(max_epsilon),
                                    num_points),
                       (num_points, 1, 1, 1))
  lin_batch = x + epsilon * eta
  logits = model.get_logits(lin_batch)
  with sess.as_default():
    log_prob_adv_array = sess.run(logits,
                                  feed_dict={x: x_data})
  return log_prob_adv_array