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: Create a neural cleanse wrapper.
  
  :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: ["Create","a","neural","cleanse","wrapper",".",":","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 __init__(
      self,
      steps: int,
      *args,
      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,
      **kwargs,
  ) -> None:
      """
      Create a neural cleanse wrapper.
  
      :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
      """
      super().__init__(*args, **kwargs)
      self.steps = steps
      self.init_cost = init_cost
      self.norm = norm
      self.learning_rate = learning_rate
      self.attack_success_threshold = attack_success_threshold
      self.patience = patience
      self.early_stop = early_stop
      self.early_stop_threshold = early_stop_threshold
      self.early_stop_patience = early_stop_patience
      self.cost_multiplier_up = cost_multiplier
      self.cost_multiplier_down = cost_multiplier**1.5
      self.batch_size = batch_size
      self.top_indices: List[int] = []
      self.activation_threshold = 0
  
file_path: adversarial-robustness-toolbox/art/estimators/poison_mitigation/neural_cleanse/neural_cleanse.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Union, Tuple, List
  import numpy
  from art.estimators.certification.abstain import AbstainPredictorMixin
  from art.utils import to_categorical
label_desc: Use image node_id 1 to create a new NeuralCleanseMixin object from inherited base classes: AbstainPredictorMixin with example: obj = NeuralCleanseMixin(steps)