class_docstr: Close implementation of Feature Collision Poisoning Attack by Shafahi, Huang, et al 2018.
  "Poison Frogs! Targeted Clean-Label Poisoning Attacks on Neural Networks"
  
  This implementation dynamically calculates the dimension of the feature layer, and doesn't hardcode this
  value to 2048 as done in the paper. Thus we recommend using larger values for the similarity_coefficient.
  
  | Paper link: https://arxiv.org/abs/1804.00792
class_docstr_tok: ["Close","implementation","of","Feature","Collision","Poisoning","Attack","by","Shafahi",",","Huang",",","et","al","2018",".","``","Poison","Frogs","!","Targeted","Clean-Label","Poisoning","Attacks","on","Neural","Networks","''","This","implementation","dynamically","calculates","the","dimension","of","the","feature","layer",",","and","does","n't","hardcode","this","value","to","2048","as","done","in","the","paper",".","Thus","we","recommend","using","larger","values","for","the","similarity_coefficient",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1804.00792"]
docstr: Initialize an Feature Collision Clean-Label poisoning attack
  
  :param classifier: A trained neural network classifier.
  :param target: The target input to misclassify at test time.
  :param feature_layer: The name of the feature representation layer.
  :param learning_rate: The learning rate of clean-label attack optimization.
  :param decay_coeff: The decay coefficient of the learning rate.
  :param stopping_tol: Stop iterations after changes in attacks in less than this threshold.
  :param obj_threshold: Stop iterations after changes in objectives values are less than this threshold.
  :param num_old_obj: The number of old objective values to store.
  :param max_iter: The maximum number of iterations for the attack.
  :param similarity_coeff: The maximum number of iterations for the attack.
  :param watermark: Whether The opacity of the watermarked target image.
  :param verbose: Show progress bars.
docstr_tok: ["Initialize","an","Feature","Collision","Clean-Label","poisoning","attack",":","param","classifier",":","A","trained","neural","network","classifier",".",":","param","target",":","The","target","input","to","misclassify","at","test","time",".",":","param","feature_layer",":","The","name","of","the","feature","representation","layer",".",":","param","learning_rate",":","The","learning","rate","of","clean-label","attack","optimization",".",":","param","decay_coeff",":","The","decay","coefficient","of","the","learning","rate",".",":","param","stopping_tol",":","Stop","iterations","after","changes","in","attacks","in","less","than","this","threshold",".",":","param","obj_threshold",":","Stop","iterations","after","changes","in","objectives","values","are","less","than","this","threshold",".",":","param","num_old_obj",":","The","number","of","old","objective","values","to","store",".",":","param","max_iter",":","The","maximum","number","of","iterations","for","the","attack",".",":","param","similarity_coeff",":","The","maximum","number","of","iterations","for","the","attack",".",":","param","watermark",":","Whether","The","opacity","of","the","watermarked","target","image",".",":","param","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
      target: np.ndarray,
      feature_layer: Union[str, int],
      learning_rate: float = 500 * 255.0,
      decay_coeff: float = 0.5,
      stopping_tol: float = 1e-10,
      obj_threshold: Optional[float] = None,
      num_old_obj: int = 40,
      max_iter: int = 120,
      similarity_coeff: float = 256.0,
      watermark: Optional[float] = None,
      verbose: bool = True,
  ):
      """
      Initialize an Feature Collision Clean-Label poisoning attack
  
      :param classifier: A trained neural network classifier.
      :param target: The target input to misclassify at test time.
      :param feature_layer: The name of the feature representation layer.
      :param learning_rate: The learning rate of clean-label attack optimization.
      :param decay_coeff: The decay coefficient of the learning rate.
      :param stopping_tol: Stop iterations after changes in attacks in less than this threshold.
      :param obj_threshold: Stop iterations after changes in objectives values are less than this threshold.
      :param num_old_obj: The number of old objective values to store.
      :param max_iter: The maximum number of iterations for the attack.
      :param similarity_coeff: The maximum number of iterations for the attack.
      :param watermark: Whether The opacity of the watermarked target image.
      :param verbose: Show progress bars.
      """
      super().__init__(classifier=classifier)  # type: ignore
      self.target = target
      self.feature_layer = feature_layer
      self.learning_rate = learning_rate
      self.decay_coeff = decay_coeff
      self.stopping_tol = stopping_tol
      self.obj_threshold = obj_threshold
      self.num_old_obj = num_old_obj
      self.max_iter = max_iter
      self.similarity_coeff = similarity_coeff
      self.watermark = watermark
      self.verbose = verbose
      self._check_params()
  
      if isinstance(self.estimator, KerasClassifier):
          (
              self.target_placeholder,
              self.target_feature_rep,
          ) = self.estimator.get_activations(
              self.target, self.feature_layer, 1, framework=True
          )
          (
              self.poison_placeholder,
              self.poison_feature_rep,
          ) = self.estimator.get_activations(
              self.target, self.feature_layer, 1, framework=True
          )
      elif isinstance(self.estimator, PyTorchClassifier):
          self.target_feature_rep = self.estimator.get_activations(
              self.target, self.feature_layer, 1, framework=True
          )
          self.poison_feature_rep = self.estimator.get_activations(
              self.target, self.feature_layer, 1, framework=True
          )
      else:
          raise ValueError("Type of estimator currently not supported.")
      self.attack_loss = tensor_norm(
          self.poison_feature_rep - self.target_feature_rep
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from functools import reduce
  import logging
  from typing import Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from tqdm.auto import trange
  from art.attacks.attack import PoisoningAttackWhiteBox
  from art.estimators import BaseEstimator, NeuralNetworkMixin
  from art.estimators.classification.classifier import ClassifierMixin
  from art.estimators.classification.keras import KerasClassifier
  from art.estimators.classification.pytorch import PyTorchClassifier
label_desc: Use image node_id 1 to create a new FeatureCollisionAttack object from inherited base classes: PoisoningAttackWhiteBox with example: obj = FeatureCollisionAttack(classifier, target, feature_layer, learning_rate, decay_coeff, stopping_tol, obj_threshold, num_old_obj, max_iter, similarity_coeff, watermark, verbose)