class_docstr: Class performing adversarial training following Madry's Protocol.
  
  | Paper link: https://arxiv.org/abs/1706.06083
  
  | Please keep in mind the limitations of defences. While adversarial training is widely regarded as a promising,
      principled approach to making classifiers more robust (see https://arxiv.org/abs/1802.00420), very careful
      evaluations are required to assess its effectiveness case by case (see https://arxiv.org/abs/1902.06705).
class_docstr_tok: ["Class","performing","adversarial","training","following","Madry","'s","Protocol",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1706.06083","|","Please","keep","in","mind","the","limitations","of","defences",".","While","adversarial","training","is","widely","regarded","as","a","promising",",","principled","approach","to","making","classifiers","more","robust","(","see","https",":","\/\/arxiv.org\/abs\/1802.00420",")",",","very","careful","evaluations","are","required","to","assess","its","effectiveness","case","by","case","(","see","https",":","\/\/arxiv.org\/abs\/1902.06705",")","."]
docstr: Create an :class:`.AdversarialTrainerMadryPGD` instance.
  
  Default values are for CIFAR-10 in pixel range 0-255.
  
  :param classifier: Classifier to train adversarially.
  :param nb_epochs: Number of training epochs.
  :param batch_size: Size of the batch on which adversarial samples are generated.
  :param eps: Maximum perturbation that the attacker can introduce.
  :param eps_step: Attack step size (input variation) at each iteration.
  :param max_iter: The maximum number of iterations.
  :param num_random_init: Number of random initialisations within the epsilon ball. For num_random_init=0
                          starting at the original input.
docstr_tok: ["Create","an",":","class",":","`",".AdversarialTrainerMadryPGD","`","instance",".","Default","values","are","for","CIFAR-10","in","pixel","range","0-255.",":","param","classifier",":","Classifier","to","train","adversarially",".",":","param","nb_epochs",":","Number","of","training","epochs",".",":","param","batch_size",":","Size","of","the","batch","on","which","adversarial","samples","are","generated",".",":","param","eps",":","Maximum","perturbation","that","the","attacker","can","introduce",".",":","param","eps_step",":","Attack","step","size","(","input","variation",")","at","each","iteration",".",":","param","max_iter",":","The","maximum","number","of","iterations",".",":","param","num_random_init",":","Number","of","random","initialisations","within","the","epsilon","ball",".","For","num_random_init=0","starting","at","the","original","input","."]
code: def __init__(
      self,
      classifier: "CLASSIFIER_LOSS_GRADIENTS_TYPE",
      nb_epochs: Optional[int] = 205,
      batch_size: Optional[int] = 128,
      eps: Union[int, float] = 8,
      eps_step: Union[int, float] = 2,
      max_iter: int = 7,
      num_random_init: int = 1,
  ) -> None:
      """
      Create an :class:`.AdversarialTrainerMadryPGD` instance.
  
      Default values are for CIFAR-10 in pixel range 0-255.
  
      :param classifier: Classifier to train adversarially.
      :param nb_epochs: Number of training epochs.
      :param batch_size: Size of the batch on which adversarial samples are generated.
      :param eps: Maximum perturbation that the attacker can introduce.
      :param eps_step: Attack step size (input variation) at each iteration.
      :param max_iter: The maximum number of iterations.
      :param num_random_init: Number of random initialisations within the epsilon ball. For num_random_init=0
                              starting at the original input.
      """
      super().__init__(classifier=classifier)  # type: ignore
      self.batch_size = batch_size
      self.nb_epochs = nb_epochs
  
      # Setting up adversary and perform adversarial training:
      self.attack = ProjectedGradientDescent(
          classifier,
          eps=eps,
          eps_step=eps_step,
          max_iter=max_iter,
          num_random_init=num_random_init,
      )
  
      self.trainer = AdversarialTrainer(
          classifier, self.attack, ratio=1.0
      )
  
file_path: adversarial-robustness-toolbox/art/defences/trainer/adversarial_trainer_madry_pgd.py
imports: import logging
  from typing import Optional, Union, TYPE_CHECKING
  import numpy
  from art.defences.trainer.trainer import Trainer
  from art.defences.trainer.adversarial_trainer import AdversarialTrainer
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent import ProjectedGradientDescent
label_desc: Use image node_id 1 to create a new AdversarialTrainerMadryPGD object from inherited base classes: Trainer with example: obj = AdversarialTrainerMadryPGD(classifier, nb_epochs, batch_size, eps, eps_step, max_iter, num_random_init)