class_docstr: Implementation of the `AutoAttack` attack.
  
  | Paper link: https://arxiv.org/abs/2003.01690
class_docstr_tok: ["Implementation","of","the","`","AutoAttack","`","attack",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2003.01690"]
docstr: Create a :class:`.AutoAttack` instance.
  
  :param estimator: An trained estimator.
  :param norm: The norm of the adversarial perturbation. Possible values: "inf", np.inf, 1 or 2.
  :param eps: Maximum perturbation that the attacker can introduce.
  :param eps_step: Attack step size (input variation) at each iteration.
  :param attacks: The list of `art.attacks.EvasionAttack` attacks to be used for AutoAttack. If it is `None` or
                  empty the standard attacks (PGD, APGD-ce, APGD-dlr, DeepFool, Square) will be used.
  :param batch_size: Size of the batch on which adversarial samples are generated.
  :param estimator_orig: Original estimator to be attacked by adversarial examples.
  :param targeted: If False run only untargeted attacks, if True also run targeted attacks against each possible
                   target.
  :param parallel: If True run attacks in parallel.
docstr_tok: ["Create","a",":","class",":","`",".AutoAttack","`","instance",".",":","param","estimator",":","An","trained","estimator",".",":","param","norm",":","The","norm","of","the","adversarial","perturbation",".","Possible","values",":","``","inf","''",",","np.inf",",","1","or","2.",":","param","eps",":","Maximum","perturbation","that","the","attacker","can","introduce",".",":","param","eps_step",":","Attack","step","size","(","input","variation",")","at","each","iteration",".",":","param","attacks",":","The","list","of","`","art.attacks.EvasionAttack","`","attacks","to","be","used","for","AutoAttack",".","If","it","is","`","None","`","or","empty","the","standard","attacks","(","PGD",",","APGD-ce",",","APGD-dlr",",","DeepFool",",","Square",")","will","be","used",".",":","param","batch_size",":","Size","of","the","batch","on","which","adversarial","samples","are","generated",".",":","param","estimator_orig",":","Original","estimator","to","be","attacked","by","adversarial","examples",".",":","param","targeted",":","If","False","run","only","untargeted","attacks",",","if","True","also","run","targeted","attacks","against","each","possible","target",".",":","param","parallel",":","If","True","run","attacks","in","parallel","."]
code: def __init__(
      self,
      estimator: "CLASSIFIER_TYPE",
      norm: Union[int, float, str] = np.inf,
      eps: float = 0.3,
      eps_step: float = 0.1,
      attacks: Optional[List[EvasionAttack]] = None,
      batch_size: int = 32,
      estimator_orig: Optional["CLASSIFIER_TYPE"] = None,
      targeted: bool = False,
      parallel: bool = False,
  ):
      """
      Create a :class:`.AutoAttack` instance.
  
      :param estimator: An trained estimator.
      :param norm: The norm of the adversarial perturbation. Possible values: "inf", np.inf, 1 or 2.
      :param eps: Maximum perturbation that the attacker can introduce.
      :param eps_step: Attack step size (input variation) at each iteration.
      :param attacks: The list of `art.attacks.EvasionAttack` attacks to be used for AutoAttack. If it is `None` or
                      empty the standard attacks (PGD, APGD-ce, APGD-dlr, DeepFool, Square) will be used.
      :param batch_size: Size of the batch on which adversarial samples are generated.
      :param estimator_orig: Original estimator to be attacked by adversarial examples.
      :param targeted: If False run only untargeted attacks, if True also run targeted attacks against each possible
                       target.
      :param parallel: If True run attacks in parallel.
      """
      super().__init__(estimator=estimator)
  
      if attacks is None or not attacks:
          attacks = []
          attacks.append(
              AutoProjectedGradientDescent(
                  estimator=estimator,  # type: ignore
                  norm=norm,
                  eps=eps,
                  eps_step=eps_step,
                  max_iter=100,
                  targeted=False,
                  nb_random_init=5,
                  batch_size=batch_size,
                  loss_type="cross_entropy",
              )
          )
          attacks.append(
              AutoProjectedGradientDescent(
                  estimator=estimator,  # type: ignore
                  norm=norm,
                  eps=eps,
                  eps_step=eps_step,
                  max_iter=100,
                  targeted=False,
                  nb_random_init=5,
                  batch_size=batch_size,
                  loss_type="difference_logits_ratio",
              )
          )
          attacks.append(
              (
                  DeepFool(
                      classifier=estimator,  # type: ignore
                      max_iter=100,
                      epsilon=1e-3,
                      nb_grads=10,
                      batch_size=batch_size,
                  )
              )
          )
          attacks.append(
              SquareAttack(
                  estimator=estimator,
                  norm=norm,
                  max_iter=5000,
                  eps=eps,
                  p_init=0.8,
                  nb_restarts=5,
              )
          )
  
      self.norm = norm
      self.eps = eps
      self.eps_step = eps_step
      self.attacks = attacks
      self.batch_size = batch_size
      if estimator_orig is not None:
          self.estimator_orig = estimator_orig
      else:
          self.estimator_orig = estimator
  
      self._targeted = targeted
      self.parallel = parallel
      self.best_attacks: np.ndarray = np.array([])
      self._check_params()
  
file_path: adversarial-robustness-toolbox/art/attacks/evasion/auto_attack.py
imports: import logging
  from copy import deepcopy
  from typing import TYPE_CHECKING, List, Optional, Tuple, Union
  import numpy
  from art.attacks.attack import EvasionAttack
  from art.attacks.evasion.auto_projected_gradient_descent import AutoProjectedGradientDescent
  from art.attacks.evasion.deepfool import DeepFool
  from art.attacks.evasion.square_attack import SquareAttack
  from art.config import ART_NUMPY_DTYPE
  from art.estimators.classification.classifier import ClassifierMixin
  from art.estimators.estimator import BaseEstimator
  from art.utils import check_and_transform_label_format, get_labels_np_array
label_desc: Use image node_id 1 to create a new AutoAttack object from inherited base classes: EvasionAttack with example: obj = AutoAttack(estimator, norm, eps, eps_step, attacks, batch_size, estimator_orig, targeted, parallel)