class_docstr: Implementation of methods in Neural Cleanse: Identifying and Mitigating Backdoor Attacks in Neural Networks.
  Wang et al. (2019).
  
  | Paper link: https://people.cs.uchicago.edu/~ravenben/publications/pdf/backdoor-sp19.pdf
class_docstr_tok: ["Implementation","of","methods","in","Neural","Cleanse",":","Identifying","and","Mitigating","Backdoor","Attacks","in","Neural","Networks",".","Wang","et","al",".","(","2019",")",".","|","Paper","link",":","https",":","\/\/people.cs.uchicago.edu\/~ravenben\/publications\/pdf\/backdoor-sp19.pdf"]
docstr: Returns an new classifier with implementation of methods in Neural Cleanse: Identifying and Mitigating Backdoor
  Attacks in Neural Networks. Wang et al. (2019).
  
  Namely, the new classifier has a new method mitigate(). This can also affect the predict() function.
  
  | Paper link: https://people.cs.uchicago.edu/~ravenben/publications/pdf/backdoor-sp19.pdf
  
  :param transformed_classifier: An ART classifier
  :param steps: The maximum number of steps to run the Neural Cleanse optimization
  :param init_cost: The initial value for the cost tensor in the Neural Cleanse optimization
  :param norm: The norm to use for the Neural Cleanse optimization, can be 1, 2, or np.inf
  :param learning_rate: The learning rate for the Neural Cleanse optimization
  :param attack_success_threshold: The threshold at which the generated backdoor is successful enough to stop the
                                   Neural Cleanse optimization
  :param patience: How long to wait for changing the cost multiplier in the Neural Cleanse optimization
  :param early_stop: Whether or not to allow early stopping in the Neural Cleanse optimization
  :param early_stop_threshold: How close values need to come to max value to start counting early stop
  :param early_stop_patience: How long to wait to determine early stopping in the Neural Cleanse optimization
  :param cost_multiplier: How much to change the cost in the Neural Cleanse optimization
  :param batch_size: The batch size for optimizations in the Neural Cleanse optimization
docstr_tok: ["Returns","an","new","classifier","with","implementation","of","methods","in","Neural","Cleanse",":","Identifying","and","Mitigating","Backdoor","Attacks","in","Neural","Networks",".","Wang","et","al",".","(","2019",")",".","Namely",",","the","new","classifier","has","a","new","method","mitigate","(",")",".","This","can","also","affect","the","predict","(",")","function",".","|","Paper","link",":","https",":","\/\/people.cs.uchicago.edu\/~ravenben\/publications\/pdf\/backdoor-sp19.pdf",":","param","transformed_classifier",":","An","ART","classifier",":","param","steps",":","The","maximum","number","of","steps","to","run","the","Neural","Cleanse","optimization",":","param","init_cost",":","The","initial","value","for","the","cost","tensor","in","the","Neural","Cleanse","optimization",":","param","norm",":","The","norm","to","use","for","the","Neural","Cleanse","optimization",",","can","be","1",",","2",",","or","np.inf",":","param","learning_rate",":","The","learning","rate","for","the","Neural","Cleanse","optimization",":","param","attack_success_threshold",":","The","threshold","at","which","the","generated","backdoor","is","successful","enough","to","stop","the","Neural","Cleanse","optimization",":","param","patience",":","How","long","to","wait","for","changing","the","cost","multiplier","in","the","Neural","Cleanse","optimization",":","param","early_stop",":","Whether","or","not","to","allow","early","stopping","in","the","Neural","Cleanse","optimization",":","param","early_stop_threshold",":","How","close","values","need","to","come","to","max","value","to","start","counting","early","stop",":","param","early_stop_patience",":","How","long","to","wait","to","determine","early","stopping","in","the","Neural","Cleanse","optimization",":","param","cost_multiplier",":","How","much","to","change","the","cost","in","the","Neural","Cleanse","optimization",":","param","batch_size",":","The","batch","size","for","optimizations","in","the","Neural","Cleanse","optimization"]
code: def __call__(  # type: ignore
      self,
      transformed_classifier: "CLASSIFIER_TYPE",
      steps: int = 1000,
      init_cost: float = 1e-3,
      norm: Union[int, float] = 2,
      learning_rate: float = 0.1,
      attack_success_threshold: float = 0.99,
      patience: int = 5,
      early_stop: bool = True,
      early_stop_threshold: float = 0.99,
      early_stop_patience: int = 10,
      cost_multiplier: float = 1.5,
      batch_size: int = 32,
  ) -> KerasNeuralCleanse:
      """
      Returns an new classifier with implementation of methods in Neural Cleanse: Identifying and Mitigating Backdoor
      Attacks in Neural Networks. Wang et al. (2019).
  
      Namely, the new classifier has a new method mitigate(). This can also affect the predict() function.
  
      | Paper link: https://people.cs.uchicago.edu/~ravenben/publications/pdf/backdoor-sp19.pdf
  
      :param transformed_classifier: An ART classifier
      :param steps: The maximum number of steps to run the Neural Cleanse optimization
      :param init_cost: The initial value for the cost tensor in the Neural Cleanse optimization
      :param norm: The norm to use for the Neural Cleanse optimization, can be 1, 2, or np.inf
      :param learning_rate: The learning rate for the Neural Cleanse optimization
      :param attack_success_threshold: The threshold at which the generated backdoor is successful enough to stop the
                                       Neural Cleanse optimization
      :param patience: How long to wait for changing the cost multiplier in the Neural Cleanse optimization
      :param early_stop: Whether or not to allow early stopping in the Neural Cleanse optimization
      :param early_stop_threshold: How close values need to come to max value to start counting early stop
      :param early_stop_patience: How long to wait to determine early stopping in the Neural Cleanse optimization
      :param cost_multiplier: How much to change the cost in the Neural Cleanse optimization
      :param batch_size: The batch size for optimizations in the Neural Cleanse optimization
      """
      transformed_classifier = KerasNeuralCleanse(
          model=transformed_classifier.model,
          steps=steps,
          init_cost=init_cost,
          norm=norm,
          learning_rate=learning_rate,
          attack_success_threshold=attack_success_threshold,
          patience=patience,
          early_stop=early_stop,
          early_stop_threshold=early_stop_threshold,
          early_stop_patience=early_stop_patience,
          cost_multiplier=cost_multiplier,
          batch_size=batch_size,
      )
      return transformed_classifier
  
file_path: adversarial-robustness-toolbox/art/defences/transformer/poisoning/neural_cleanse.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, TYPE_CHECKING, Union
  import numpy
  from art.defences.transformer.transformer import Transformer
  from art.estimators.poison_mitigation.neural_cleanse import KerasNeuralCleanse
  from art.estimators.classification.keras import KerasClassifier
label_desc: Use image node_id 2 for calling the NeuralCleanse obj's underlying member method code with example usage: obj.__call__(transformed_classifier, steps, init_cost, norm, learning_rate, attack_success_threshold, patience, early_stop, early_stop_threshold, early_stop_patience, cost_multiplier, batch_size) and returns: transformed_classifier