class_docstr: Implementation of the adversarial patch attack for square and rectangular images and videos.
  
  | Paper link: https://arxiv.org/abs/1712.09665
class_docstr_tok: ["Implementation","of","the","adversarial","patch","attack","for","square","and","rectangular","images","and","videos",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1712.09665"]
docstr: Create an instance of the :class:`.AdversarialPatch`.
  
  :param classifier: A trained classifier.
  :param rotation_max: The maximum rotation applied to random patches. The value is expected to be in the
         range `[0, 180]`.
  :param scale_min: The minimum scaling applied to random patches. The value should be in the range `[0, 1]`,
         but less than `scale_max`.
  :param scale_max: The maximum scaling applied to random patches. The value should be in the range `[0, 1]`, but
         larger than `scale_min.`
  :param learning_rate: The learning rate of the optimization.
  :param max_iter: The number of optimization steps.
  :param batch_size: The size of the training batch.
  :param patch_shape: The shape of the adversarial patch as a tuple of shape (width, height, nb_channels).
                      Currently only supported for `TensorFlowV2Classifier`. For classifiers of other frameworks
                      the `patch_shape` is set to the shape of the input samples.
  :param targeted: Indicates whether the attack is targeted (True) or untargeted (False).
  :param verbose: Show progress bars.
docstr_tok: ["Create","an","instance","of","the",":","class",":","`",".AdversarialPatch","`",".",":","param","classifier",":","A","trained","classifier",".",":","param","rotation_max",":","The","maximum","rotation","applied","to","random","patches",".","The","value","is","expected","to","be","in","the","range","`","[","0",",","180","]","`",".",":","param","scale_min",":","The","minimum","scaling","applied","to","random","patches",".","The","value","should","be","in","the","range","`","[","0",",","1","]","`",",","but","less","than","`","scale_max","`",".",":","param","scale_max",":","The","maximum","scaling","applied","to","random","patches",".","The","value","should","be","in","the","range","`","[","0",",","1","]","`",",","but","larger","than","`","scale_min.","`",":","param","learning_rate",":","The","learning","rate","of","the","optimization",".",":","param","max_iter",":","The","number","of","optimization","steps",".",":","param","batch_size",":","The","size","of","the","training","batch",".",":","param","patch_shape",":","The","shape","of","the","adversarial","patch","as","a","tuple","of","shape","(","width",",","height",",","nb_channels",")",".","Currently","only","supported","for","`","TensorFlowV2Classifier","`",".","For","classifiers","of","other","frameworks","the","`","patch_shape","`","is","set","to","the","shape","of","the","input","samples",".",":","param","targeted",":","Indicates","whether","the","attack","is","targeted","(","True",")","or","untargeted","(","False",")",".",":","param","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
      rotation_max: float = 22.5,
      scale_min: float = 0.1,
      scale_max: float = 1.0,
      learning_rate: float = 5.0,
      max_iter: int = 500,
      batch_size: int = 16,
      patch_shape: Optional[Tuple[int, int, int]] = None,
      targeted: bool = True,
      verbose: bool = True,
  ):
      """
      Create an instance of the :class:`.AdversarialPatch`.
  
      :param classifier: A trained classifier.
      :param rotation_max: The maximum rotation applied to random patches. The value is expected to be in the
             range `[0, 180]`.
      :param scale_min: The minimum scaling applied to random patches. The value should be in the range `[0, 1]`,
             but less than `scale_max`.
      :param scale_max: The maximum scaling applied to random patches. The value should be in the range `[0, 1]`, but
             larger than `scale_min.`
      :param learning_rate: The learning rate of the optimization.
      :param max_iter: The number of optimization steps.
      :param batch_size: The size of the training batch.
      :param patch_shape: The shape of the adversarial patch as a tuple of shape (width, height, nb_channels).
                          Currently only supported for `TensorFlowV2Classifier`. For classifiers of other frameworks
                          the `patch_shape` is set to the shape of the input samples.
      :param targeted: Indicates whether the attack is targeted (True) or untargeted (False).
      :param verbose: Show progress bars.
      """
      super().__init__(estimator=classifier)
      if self.estimator.clip_values is None:  # pragma: no cover
          raise ValueError(
              "Adversarial Patch attack requires a classifier with clip_values."
          )
  
      self._attack: Union[
          AdversarialPatchTensorFlowV2,
          AdversarialPatchPyTorch,
          AdversarialPatchNumpy,
      ]
      if isinstance(self.estimator, TensorFlowV2Classifier):
          self._attack = AdversarialPatchTensorFlowV2(
              classifier=classifier,
              rotation_max=rotation_max,
              scale_min=scale_min,
              scale_max=scale_max,
              learning_rate=learning_rate,
              max_iter=max_iter,
              batch_size=batch_size,
              patch_shape=patch_shape,
              targeted=targeted,
              verbose=verbose,
          )
      elif isinstance(self.estimator, PyTorchClassifier):
          if patch_shape is not None:
              self._attack = AdversarialPatchPyTorch(
                  estimator=classifier,
                  rotation_max=rotation_max,
                  scale_min=scale_min,
                  scale_max=scale_max,
                  distortion_scale_max=0.0,
                  learning_rate=learning_rate,
                  max_iter=max_iter,
                  batch_size=batch_size,
                  patch_shape=patch_shape,
                  patch_type="circle",
                  targeted=targeted,
                  verbose=verbose,
              )
          else:
              raise ValueError(
                  "`patch_shape` cannot be `None` for `AdversarialPatchPyTorch`."
              )
      else:
          self._attack = AdversarialPatchNumpy(
              classifier=classifier,
              rotation_max=rotation_max,
              scale_min=scale_min,
              scale_max=scale_max,
              learning_rate=learning_rate,
              max_iter=max_iter,
              batch_size=batch_size,
              targeted=targeted,
              verbose=verbose,
          )
      self._check_params()
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.attacks.evasion.adversarial_patch.adversarial_patch_numpy import AdversarialPatchNumpy
  from art.attacks.evasion.adversarial_patch.adversarial_patch_tensorflow import AdversarialPatchTensorFlowV2
  from art.attacks.evasion.adversarial_patch.adversarial_patch_pytorch import AdversarialPatchPyTorch
  from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.estimators.classification import TensorFlowV2Classifier, PyTorchClassifier
  from art.attacks.attack import EvasionAttack
label_desc: Use image node_id 1 to create a new AdversarialPatch object from inherited base classes: EvasionAttack with example: obj = AdversarialPatch(classifier, rotation_max, scale_min, scale_max, learning_rate, max_iter, batch_size, patch_shape, targeted, verbose)