class_docstr: This is a fast implementation of "Feature Adversaries", an attack
  against a target internal representation of a model.
  "Feature adversaries" were originally introduced in (Sabour et al. 2016),
  where the optimization was done using LBFGS.
  Paper link: https://arxiv.org/abs/1511.05122
  
  This implementation is similar to "Basic Iterative Method"
  (Kurakin et al. 2016) but applied to the internal representations.
  
  :param model: cleverhans.model.Model
  :param sess: optional tf.Session
  :param dtypestr: dtype of the data
  :param kwargs: passed through to super constructor
class_docstr_tok: ["This","is","a","fast","implementation","of","``","Feature","Adversaries","''",",","an","attack","against","a","target","internal","representation","of","a","model",".","``","Feature","adversaries","''","were","originally","introduced","in","(","Sabour","et","al",".","2016",")",",","where","the","optimization","was","done","using","LBFGS",".","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1511.05122","This","implementation","is","similar","to","``","Basic","Iterative","Method","''","(","Kurakin","et","al",".","2016",")","but","applied","to","the","internal","representations",".",":","param","model",":","cleverhans.model.Model",":","param","sess",":","optional","tf.Session",":","param","dtypestr",":","dtype","of","the","data",":","param","kwargs",":","passed","through","to","super","constructor"]
docstr: Generate symbolic graph for adversarial examples and return.
  
  :param x: The model's symbolic inputs.
  :param g: The target value of the symbolic representation
  :param kwargs: See `parse_params`
docstr_tok: ["Generate","symbolic","graph","for","adversarial","examples","and","return",".",":","param","x",":","The","model","'s","symbolic","inputs",".",":","param","g",":","The","target","value","of","the","symbolic","representation",":","param","kwargs",":","See","`","parse_params","`"]
code: def generate(self, x, g, **kwargs):
      """
      Generate symbolic graph for adversarial examples and return.
  
      :param x: The model's symbolic inputs.
      :param g: The target value of the symbolic representation
      :param kwargs: See `parse_params`
      """
  
      # Parse and save attack-specific parameters
      assert self.parse_params(**kwargs)
  
      g_feat = self.model.fprop(g)[self.layer]
  
      # Initialize loop variables
      eta = tf.random_uniform(
          tf.shape(x), -self.eps, self.eps, dtype=self.tf_dtype
      )
      eta = clip_eta(eta, self.ord, self.eps)
  
      def cond(i, _):
          return tf.less(i, self.nb_iter)
  
      def body(i, e):
          new_eta = self.attack_single_step(x, e, g_feat)
          return i + 1, new_eta
  
      _, eta = tf.while_loop(
          cond,
          body,
          (tf.zeros([]), eta),
          back_prop=True,
          maximum_iterations=self.nb_iter,
      )
  
      # Define adversarial example (and clip if necessary)
      adv_x = x + eta
      if self.clip_min is not None and self.clip_max is not None:
          adv_x = tf.clip_by_value(adv_x, self.clip_min, self.clip_max)
  
      return adv_x
  
file_path: cleverhans/cleverhans_v3.1.0/cleverhans/attacks/fast_feature_adversaries.py
imports: import warnings
  import numpy
  import tensorflow
  from cleverhans.attacks.attack import Attack
  from cleverhans.compat import reduce_sum
  from cleverhans.model import Model
  from cleverhans.utils_tf import clip_eta
label_desc: Use image node_id 4 for calling the FastFeatureAdversaries obj's underlying member method code with example usage: obj.generate(x, g) and returns: adv_x, tf, unknown,  new_eta