class_docstr: Implementation of the DPatch attack.
  
  | Paper link: https://arxiv.org/abs/1806.02299v4
class_docstr_tok: ["Implementation","of","the","DPatch","attack",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1806.02299v4"]
docstr: Create an instance of the :class:`.DPatch`.
  
  :param estimator: A trained object detector.
  :param patch_shape: The shape of the adversarial path as a tuple of shape (height, width, nb_channels).
  :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 verbose: Show progress bars.
docstr_tok: ["Create","an","instance","of","the",":","class",":","`",".DPatch","`",".",":","param","estimator",":","A","trained","object","detector",".",":","param","patch_shape",":","The","shape","of","the","adversarial","path","as","a","tuple","of","shape","(","height",",","width",",","nb_channels",")",".",":","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","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      estimator: "OBJECT_DETECTOR_TYPE",
      patch_shape: Tuple[int, int, int] = (40, 40, 3),
      learning_rate: float = 5.0,
      max_iter: int = 500,
      batch_size: int = 16,
      verbose: bool = True,
  ):
      """
      Create an instance of the :class:`.DPatch`.
  
      :param estimator: A trained object detector.
      :param patch_shape: The shape of the adversarial path as a tuple of shape (height, width, nb_channels).
      :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 verbose: Show progress bars.
      """
      super().__init__(estimator=estimator)
  
      self.patch_shape = patch_shape
      self.learning_rate = learning_rate
      self.max_iter = max_iter
      self.batch_size = batch_size
      self.verbose = verbose
      self._check_params()
  
      if self.estimator.clip_values is None:
          self._patch = np.zeros(
              shape=patch_shape, dtype=config.ART_NUMPY_DTYPE
          )
      else:
          self._patch = (
              np.random.randint(0, 255, size=patch_shape)
              / 255
              * (
                  self.estimator.clip_values[1]
                  - self.estimator.clip_values[0]
              )
              + self.estimator.clip_values[0]
          ).astype(config.ART_NUMPY_DTYPE)
  
      self.target_label: Optional[
          Union[int, np.ndarray, List[int]]
      ] = []
  
file_path: adversarial-robustness-toolbox/art/attacks/evasion/dpatch.py
imports: import logging
  import math
  import random
  from typing import Dict, List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from tqdm.auto import trange
  from art.attacks.attack import EvasionAttack
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.estimators.object_detection.object_detector import ObjectDetectorMixin
  from art import config
label_desc: Use image node_id 1 to create a new DPatch object from inherited base classes: EvasionAttack with example: obj = DPatch(estimator, patch_shape, learning_rate, max_iter, batch_size, verbose)