class_docstr: Implementation of Hidden Trigger Backdoor Attack by Saha et al 2019.
  "Hidden Trigger Backdoor Attacks
  
  | Paper link: https://arxiv.org/abs/1910.00033
class_docstr_tok: ["Implementation","of","Hidden","Trigger","Backdoor","Attack","by","Saha","et","al","2019",".","``","Hidden","Trigger","Backdoor","Attacks","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1910.00033"]
docstr: Creates a new Hidden Trigger Backdoor poisoning attack for Keras and TensorflowV2.
  
  :param classifier: A trained neural network classifier.
  :param target: The target class/indices to poison. Triggers added to inputs not in the target class will
                 result in misclassifications to the target class. If an int, it represents a label.
                 Otherwise, it is an array of indices.
  :param source: The class/indices which will have a trigger added to cause misclassification
                 If an int, it represents a label. Otherwise, it is an array of indices.
  :param feature_layer: The name of the feature representation layer.
  :param backdoor: A PoisoningAttackBackdoor that adds a backdoor trigger to the input.
  :param eps: Maximum perturbation that the attacker can introduce.
  :param learning_rate: The learning rate of clean-label attack optimization.
  :param decay_coeff: The decay coefficient of the learning rate.
  :param decay_iter: The number of iterations before the learning rate decays
  :param stopping_threshold: Stop iterations after loss is less than this threshold.
  :param max_iter: The maximum number of iterations for the attack.
  :param batch_size: The number of samples to draw per batch.
  :param poison_percent: The percentage of the data to poison. This is ignored if indices are provided
  :param is_index: If true, the source and target params are assumed to represent indices rather
                   than a class label. poison_percent is ignored if true.
  :param verbose: Show progress bars.
  :print iter: The number of iterations to print the current loss progress.
docstr_tok: ["Creates","a","new","Hidden","Trigger","Backdoor","poisoning","attack","for","Keras","and","TensorflowV2",".",":","param","classifier",":","A","trained","neural","network","classifier",".",":","param","target",":","The","target","class\/indices","to","poison",".","Triggers","added","to","inputs","not","in","the","target","class","will","result","in","misclassifications","to","the","target","class",".","If","an","int",",","it","represents","a","label",".","Otherwise",",","it","is","an","array","of","indices",".",":","param","source",":","The","class\/indices","which","will","have","a","trigger","added","to","cause","misclassification","If","an","int",",","it","represents","a","label",".","Otherwise",",","it","is","an","array","of","indices",".",":","param","feature_layer",":","The","name","of","the","feature","representation","layer",".",":","param","backdoor",":","A","PoisoningAttackBackdoor","that","adds","a","backdoor","trigger","to","the","input",".",":","param","eps",":","Maximum","perturbation","that","the","attacker","can","introduce",".",":","param","learning_rate",":","The","learning","rate","of","clean-label","attack","optimization",".",":","param","decay_coeff",":","The","decay","coefficient","of","the","learning","rate",".",":","param","decay_iter",":","The","number","of","iterations","before","the","learning","rate","decays",":","param","stopping_threshold",":","Stop","iterations","after","loss","is","less","than","this","threshold",".",":","param","max_iter",":","The","maximum","number","of","iterations","for","the","attack",".",":","param","batch_size",":","The","number","of","samples","to","draw","per","batch",".",":","param","poison_percent",":","The","percentage","of","the","data","to","poison",".","This","is","ignored","if","indices","are","provided",":","param","is_index",":","If","true",",","the","source","and","target","params","are","assumed","to","represent","indices","rather","than","a","class","label",".","poison_percent","is","ignored","if","true",".",":","param","verbose",":","Show","progress","bars",".",":","print","iter",":","The","number","of","iterations","to","print","the","current","loss","progress","."]
code: def __init__(
      self,
      classifier: Union["KerasClassifier", "TensorFlowV2Classifier"],
      target: np.ndarray,
      source: np.ndarray,
      feature_layer: Union[str, int],
      backdoor: PoisoningAttackBackdoor,
      eps: float = 0.1,
      learning_rate: float = 0.001,
      decay_coeff: float = 0.95,
      decay_iter: Union[int, List[int]] = 2000,
      stopping_threshold: float = 10,
      max_iter: int = 5000,
      batch_size: float = 100,
      poison_percent: float = 0.1,
      is_index: bool = False,
      verbose: bool = True,
      print_iter: int = 100,
  ) -> None:
      """
      Creates a new Hidden Trigger Backdoor poisoning attack for Keras and TensorflowV2.
  
      :param classifier: A trained neural network classifier.
      :param target: The target class/indices to poison. Triggers added to inputs not in the target class will
                     result in misclassifications to the target class. If an int, it represents a label.
                     Otherwise, it is an array of indices.
      :param source: The class/indices which will have a trigger added to cause misclassification
                     If an int, it represents a label. Otherwise, it is an array of indices.
      :param feature_layer: The name of the feature representation layer.
      :param backdoor: A PoisoningAttackBackdoor that adds a backdoor trigger to the input.
      :param eps: Maximum perturbation that the attacker can introduce.
      :param learning_rate: The learning rate of clean-label attack optimization.
      :param decay_coeff: The decay coefficient of the learning rate.
      :param decay_iter: The number of iterations before the learning rate decays
      :param stopping_threshold: Stop iterations after loss is less than this threshold.
      :param max_iter: The maximum number of iterations for the attack.
      :param batch_size: The number of samples to draw per batch.
      :param poison_percent: The percentage of the data to poison. This is ignored if indices are provided
      :param is_index: If true, the source and target params are assumed to represent indices rather
                       than a class label. poison_percent is ignored if true.
      :param verbose: Show progress bars.
      :print iter: The number of iterations to print the current loss progress.
      """
      super().__init__(classifier=classifier)  # type: ignore
      self.target = target
      self.source = source
      self.feature_layer = feature_layer
      self.backdoor = backdoor
      self.eps = eps
      self.learning_rate = learning_rate
      self.decay_coeff = decay_coeff
      self.decay_iter = decay_iter
      self.stopping_threshold = stopping_threshold
      self.max_iter = max_iter
      self.batch_size = batch_size
      self.poison_percent = poison_percent
      self.is_index = is_index
      self.verbose = verbose
      self.print_iter = print_iter
  
file_path: adversarial-robustness-toolbox/art/attacks/poisoning/hidden_trigger_backdoor/hidden_trigger_backdoor_keras.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import List, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  import six
  from tqdm.auto import trange
  from art.attacks.attack import PoisoningAttackWhiteBox
  from art.attacks.poisoning.backdoor_attack import PoisoningAttackBackdoor
  from art.estimators import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.estimators.classification.keras import KerasClassifier
  from art.attacks.poisoning.hidden_trigger_backdoor.loss_meter import LossMeter
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 1 to create a new HiddenTriggerBackdoorKeras object from inherited base classes: PoisoningAttackWhiteBox with example: obj = HiddenTriggerBackdoorKeras(classifier, target, source, feature_layer, backdoor, eps, learning_rate, decay_coeff, decay_iter, stopping_threshold, max_iter, batch_size, poison_percent, is_index, verbose, print_iter)