class_docstr: Implementation of the ShapeShifter attack. This is a robust physical adversarial attack on Faster R-CNN object
  detector and is developed in TensorFlow.
  
  | Paper link: https://arxiv.org/abs/1804.05810
class_docstr_tok: ["Implementation","of","the","ShapeShifter","attack",".","This","is","a","robust","physical","adversarial","attack","on","Faster","R-CNN","object","detector","and","is","developed","in","TensorFlow",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1804.05810"]
docstr: Create an instance of the :class:`.ShapeShifter`.
  
  :param estimator: A trained object detector.
  :param random_transform: A function applies random transformations to images/textures.
  :param box_classifier_weight: Weight of box classifier loss.
  :param box_localizer_weight: Weight of box localizer loss.
  :param rpn_classifier_weight: Weight of RPN classifier loss.
  :param rpn_localizer_weight: Weight of RPN localizer loss.
  :param box_iou_threshold: Box intersection over union threshold.
  :param box_victim_weight: Weight of box victim loss.
  :param box_target_weight: Weight of box target loss.
  :param box_victim_cw_weight: Weight of box victim CW loss.
  :param box_victim_cw_confidence: Confidence of box victim CW loss.
  :param box_target_cw_weight: Weight of box target CW loss.
  :param box_target_cw_confidence: Confidence of box target CW loss.
  :param rpn_iou_threshold: RPN intersection over union threshold.
  :param rpn_background_weight: Weight of RPN background loss.
  :param rpn_foreground_weight: Weight of RPN foreground loss.
  :param rpn_cw_weight: Weight of RPN CW loss.
  :param rpn_cw_confidence: Confidence of RPN CW loss.
  :param similarity_weight: Weight of similarity loss.
  :param learning_rate: Learning rate.
  :param optimizer: Optimizer including one of the following choices: `GradientDescentOptimizer`,
                    `MomentumOptimizer`, `RMSPropOptimizer`, `AdamOptimizer`.
  :param momentum: Momentum for `RMSPropOptimizer`, `MomentumOptimizer`.
  :param decay: Learning rate decay for `RMSPropOptimizer`.
  :param sign_gradients: Whether to use the sign of gradients for optimization.
  :param random_size: Random sample size.
  :param max_iter: Maximum number of iterations.
  :param texture_as_input: Whether textures are used as inputs instead of images.
  :param use_spectral: Whether to use spectral with textures.
  :param soft_clip: Whether to apply soft clipping on textures.
docstr_tok: ["Create","an","instance","of","the",":","class",":","`",".ShapeShifter","`",".",":","param","estimator",":","A","trained","object","detector",".",":","param","random_transform",":","A","function","applies","random","transformations","to","images\/textures",".",":","param","box_classifier_weight",":","Weight","of","box","classifier","loss",".",":","param","box_localizer_weight",":","Weight","of","box","localizer","loss",".",":","param","rpn_classifier_weight",":","Weight","of","RPN","classifier","loss",".",":","param","rpn_localizer_weight",":","Weight","of","RPN","localizer","loss",".",":","param","box_iou_threshold",":","Box","intersection","over","union","threshold",".",":","param","box_victim_weight",":","Weight","of","box","victim","loss",".",":","param","box_target_weight",":","Weight","of","box","target","loss",".",":","param","box_victim_cw_weight",":","Weight","of","box","victim","CW","loss",".",":","param","box_victim_cw_confidence",":","Confidence","of","box","victim","CW","loss",".",":","param","box_target_cw_weight",":","Weight","of","box","target","CW","loss",".",":","param","box_target_cw_confidence",":","Confidence","of","box","target","CW","loss",".",":","param","rpn_iou_threshold",":","RPN","intersection","over","union","threshold",".",":","param","rpn_background_weight",":","Weight","of","RPN","background","loss",".",":","param","rpn_foreground_weight",":","Weight","of","RPN","foreground","loss",".",":","param","rpn_cw_weight",":","Weight","of","RPN","CW","loss",".",":","param","rpn_cw_confidence",":","Confidence","of","RPN","CW","loss",".",":","param","similarity_weight",":","Weight","of","similarity","loss",".",":","param","learning_rate",":","Learning","rate",".",":","param","optimizer",":","Optimizer","including","one","of","the","following","choices",":","`","GradientDescentOptimizer","`",",","`","MomentumOptimizer","`",",","`","RMSPropOptimizer","`",",","`","AdamOptimizer","`",".",":","param","momentum",":","Momentum","for","`","RMSPropOptimizer","`",",","`","MomentumOptimizer","`",".",":","param","decay",":","Learning","rate","decay","for","`","RMSPropOptimizer","`",".",":","param","sign_gradients",":","Whether","to","use","the","sign","of","gradients","for","optimization",".",":","param","random_size",":","Random","sample","size",".",":","param","max_iter",":","Maximum","number","of","iterations",".",":","param","texture_as_input",":","Whether","textures","are","used","as","inputs","instead","of","images",".",":","param","use_spectral",":","Whether","to","use","spectral","with","textures",".",":","param","soft_clip",":","Whether","to","apply","soft","clipping","on","textures","."]
code: def __init__(
      self,
      estimator: TensorFlowFasterRCNN,
      random_transform: "Callable",
      box_classifier_weight: float = 1.0,
      box_localizer_weight: float = 2.0,
      rpn_classifier_weight: float = 1.0,
      rpn_localizer_weight: float = 2.0,
      box_iou_threshold: float = 0.5,
      box_victim_weight: float = 0.0,
      box_target_weight: float = 0.0,
      box_victim_cw_weight: float = 0.0,
      box_victim_cw_confidence: float = 0.0,
      box_target_cw_weight: float = 0.0,
      box_target_cw_confidence: float = 0.0,
      rpn_iou_threshold: float = 0.5,
      rpn_background_weight: float = 0.0,
      rpn_foreground_weight: float = 0.0,
      rpn_cw_weight: float = 0.0,
      rpn_cw_confidence: float = 0.0,
      similarity_weight: float = 0.0,
      learning_rate: float = 1.0,
      optimizer: str = "GradientDescentOptimizer",
      momentum: float = 0.0,
      decay: float = 0.0,
      sign_gradients: bool = False,
      random_size: int = 10,
      max_iter: int = 10,
      texture_as_input: bool = False,
      use_spectral: bool = True,
      soft_clip: bool = False,
  ):
      """
      Create an instance of the :class:`.ShapeShifter`.
  
      :param estimator: A trained object detector.
      :param random_transform: A function applies random transformations to images/textures.
      :param box_classifier_weight: Weight of box classifier loss.
      :param box_localizer_weight: Weight of box localizer loss.
      :param rpn_classifier_weight: Weight of RPN classifier loss.
      :param rpn_localizer_weight: Weight of RPN localizer loss.
      :param box_iou_threshold: Box intersection over union threshold.
      :param box_victim_weight: Weight of box victim loss.
      :param box_target_weight: Weight of box target loss.
      :param box_victim_cw_weight: Weight of box victim CW loss.
      :param box_victim_cw_confidence: Confidence of box victim CW loss.
      :param box_target_cw_weight: Weight of box target CW loss.
      :param box_target_cw_confidence: Confidence of box target CW loss.
      :param rpn_iou_threshold: RPN intersection over union threshold.
      :param rpn_background_weight: Weight of RPN background loss.
      :param rpn_foreground_weight: Weight of RPN foreground loss.
      :param rpn_cw_weight: Weight of RPN CW loss.
      :param rpn_cw_confidence: Confidence of RPN CW loss.
      :param similarity_weight: Weight of similarity loss.
      :param learning_rate: Learning rate.
      :param optimizer: Optimizer including one of the following choices: `GradientDescentOptimizer`,
                        `MomentumOptimizer`, `RMSPropOptimizer`, `AdamOptimizer`.
      :param momentum: Momentum for `RMSPropOptimizer`, `MomentumOptimizer`.
      :param decay: Learning rate decay for `RMSPropOptimizer`.
      :param sign_gradients: Whether to use the sign of gradients for optimization.
      :param random_size: Random sample size.
      :param max_iter: Maximum number of iterations.
      :param texture_as_input: Whether textures are used as inputs instead of images.
      :param use_spectral: Whether to use spectral with textures.
      :param soft_clip: Whether to apply soft clipping on textures.
      """
      super().__init__(estimator=estimator)
  
      # Set attack attributes
      self.random_transform = random_transform
      self.box_classifier_weight = box_classifier_weight
      self.box_localizer_weight = box_localizer_weight
      self.rpn_classifier_weight = rpn_classifier_weight
      self.rpn_localizer_weight = rpn_localizer_weight
      self.box_iou_threshold = box_iou_threshold
      self.box_victim_weight = box_victim_weight
      self.box_target_weight = box_target_weight
      self.box_victim_cw_weight = box_victim_cw_weight
      self.box_victim_cw_confidence = box_victim_cw_confidence
      self.box_target_cw_weight = box_target_cw_weight
      self.box_target_cw_confidence = box_target_cw_confidence
      self.rpn_iou_threshold = rpn_iou_threshold
      self.rpn_background_weight = rpn_background_weight
      self.rpn_foreground_weight = rpn_foreground_weight
      self.rpn_cw_weight = rpn_cw_weight
      self.rpn_cw_confidence = rpn_cw_confidence
      self.similarity_weight = similarity_weight
      self.learning_rate = learning_rate
      self.optimizer = optimizer
      self.momentum = momentum
      self.decay = decay
      self.sign_gradients = sign_gradients
      self.random_size = random_size
      self.max_iter = max_iter
      self.texture_as_input = texture_as_input
      self.use_spectral = use_spectral
      self.soft_clip = soft_clip
      self.graph_available: bool = False
  
      # Check validity of attack attributes
      self._check_params()
  
file_path: adversarial-robustness-toolbox/art/attacks/evasion/shapeshifter.py
imports: import logging
  from typing import List, Dict, Optional, Tuple, TYPE_CHECKING
  import numpy
  from art.attacks.attack import EvasionAttack
  from art.estimators.object_detection.tensorflow_faster_rcnn import TensorFlowFasterRCNN
label_desc: Use image node_id 1 to create a new ShapeShifter object from inherited base classes: EvasionAttack with example: obj = ShapeShifter(estimator, random_transform, box_classifier_weight, box_localizer_weight, rpn_classifier_weight, rpn_localizer_weight, box_iou_threshold, box_victim_weight, box_target_weight, box_victim_cw_weight, box_victim_cw_confidence, box_target_cw_weight, box_target_cw_confidence, rpn_iou_threshold, rpn_background_weight, rpn_foreground_weight, rpn_cw_weight, rpn_cw_confidence, similarity_weight, learning_rate, optimizer, momentum, decay, sign_gradients, random_size, max_iter, texture_as_input, use_spectral, soft_clip)