class_docstr: Implementation of Gradient Matching Attack by Geiping, et. al. 2020.
  "Witches' Brew: Industrial Scale Data Poisoning via Gradient Matching"
  
  | Paper link: https://arxiv.org/abs/2009.02276
class_docstr_tok: ["Implementation","of","Gradient","Matching","Attack","by","Geiping",",","et",".","al",".","2020",".","``","Witches","'","Brew",":","Industrial","Scale","Data","Poisoning","via","Gradient","Matching","''","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/2009.02276"]
docstr: Initialize a Gradient Matching Clean-Label poisoning attack (Witches' Brew).
  
  :param classifier: The proxy classifier used for the attack.
  :param percent_poison: The ratio of samples to poison among x_train, with range [0,1].
  :param epsilon: The L-inf perturbation budget.
  :param max_trials: The maximum number of restarts to optimize the poison.
  :param max_epochs: The maximum number of epochs to optimize the train per trial.
  :param learning_rate_schedule: The learning rate schedule to optimize the poison.
      A List of (learning rate, epoch) pairs. The learning rate is used
      if the current epoch is less than the specified epoch.
  :param batch_size: Batch size.
  :param clip_values: The range of the input features to the classifier.
  :param verbose: Show progress bars.
docstr_tok: ["Initialize","a","Gradient","Matching","Clean-Label","poisoning","attack","(","Witches","'","Brew",")",".",":","param","classifier",":","The","proxy","classifier","used","for","the","attack",".",":","param","percent_poison",":","The","ratio","of","samples","to","poison","among","x_train",",","with","range","[","0,1","]",".",":","param","epsilon",":","The","L-inf","perturbation","budget",".",":","param","max_trials",":","The","maximum","number","of","restarts","to","optimize","the","poison",".",":","param","max_epochs",":","The","maximum","number","of","epochs","to","optimize","the","train","per","trial",".",":","param","learning_rate_schedule",":","The","learning","rate","schedule","to","optimize","the","poison",".","A","List","of","(","learning","rate",",","epoch",")","pairs",".","The","learning","rate","is","used","if","the","current","epoch","is","less","than","the","specified","epoch",".",":","param","batch_size",":","Batch","size",".",":","param","clip_values",":","The","range","of","the","input","features","to","the","classifier",".",":","param","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
      percent_poison: float,
      epsilon: float = 0.1,
      max_trials: int = 8,
      max_epochs: int = 250,
      learning_rate_schedule: Tuple[List[float], List[int]] = (
          [1e-1, 1e-2, 1e-3, 1e-4],
          [100, 150, 200, 220],
      ),
      batch_size: int = 128,
      clip_values: Tuple[float, float] = (0, 1.0),
      verbose: int = 1,
  ):
      """
      Initialize a Gradient Matching Clean-Label poisoning attack (Witches' Brew).
  
      :param classifier: The proxy classifier used for the attack.
      :param percent_poison: The ratio of samples to poison among x_train, with range [0,1].
      :param epsilon: The L-inf perturbation budget.
      :param max_trials: The maximum number of restarts to optimize the poison.
      :param max_epochs: The maximum number of epochs to optimize the train per trial.
      :param learning_rate_schedule: The learning rate schedule to optimize the poison.
          A List of (learning rate, epoch) pairs. The learning rate is used
          if the current epoch is less than the specified epoch.
      :param batch_size: Batch size.
      :param clip_values: The range of the input features to the classifier.
      :param verbose: Show progress bars.
      """
      self.substitute_classifier = classifier
  
      super().__init__(classifier)
      self.percent_poison = percent_poison
      self.epsilon = epsilon
      self.learning_rate_schedule = learning_rate_schedule
      self.max_trials = max_trials
      self.max_epochs = max_epochs
      self.batch_size = batch_size
      self.clip_values = clip_values
      self.initial_epoch = 0
  
      if verbose is True:
          verbose = 1
      self.verbose = verbose
      self._check_params()
  
file_path: adversarial-robustness-toolbox/art/attacks/poisoning/gradient_matching_attack.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Any, Dict, Tuple, TYPE_CHECKING, List
  import numpy
  from tqdm.auto import trange, tqdm
  from art.attacks.attack import Attack
  from art.estimators import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
label_desc: Use image node_id 1 to create a new GradientMatchingAttack object from inherited base classes: Attack with example: obj = GradientMatchingAttack(classifier, percent_poison, epsilon, max_trials, max_epochs, learning_rate_schedule, batch_size, clip_values, verbose)