class_docstr: Binary detector of adversarial samples coming from evasion attacks. The detector uses an architecture provided by
  the user and is trained on the values of the activations of a classifier at a given layer.
class_docstr_tok: ["Binary","detector","of","adversarial","samples","coming","from","evasion","attacks",".","The","detector","uses","an","architecture","provided","by","the","user","and","is","trained","on","the","values","of","the","activations","of","a","classifier","at","a","given","layer","."]
docstr: Create a `BinaryActivationDetector` instance which performs binary classification on activation information.
  The shape of the input of the detector has to match that of the output of the chosen layer.
  
  :param classifier: The classifier of which the activation information is to be used for detection.
  :param detector: The detector architecture to be trained and applied for the binary classification.
  :param layer: Layer for computing the activations to use for training the detector.
docstr_tok: ["Create","a","`","BinaryActivationDetector","`","instance","which","performs","binary","classification","on","activation","information",".","The","shape","of","the","input","of","the","detector","has","to","match","that","of","the","output","of","the","chosen","layer",".",":","param","classifier",":","The","classifier","of","which","the","activation","information","is","to","be","used","for","detection",".",":","param","detector",":","The","detector","architecture","to","be","trained","and","applied","for","the","binary","classification",".",":","param","layer",":","Layer","for","computing","the","activations","to","use","for","training","the","detector","."]
code: def __init__(
      self,
      classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
      detector: "CLASSIFIER_NEURALNETWORK_TYPE",
      layer: Union[int, str],
  ) -> None:
      """
      Create a `BinaryActivationDetector` instance which performs binary classification on activation information.
      The shape of the input of the detector has to match that of the output of the chosen layer.
  
      :param classifier: The classifier of which the activation information is to be used for detection.
      :param detector: The detector architecture to be trained and applied for the binary classification.
      :param layer: Layer for computing the activations to use for training the detector.
      """
      super().__init__()
      self.classifier = classifier
      self.detector = detector
  
      # Ensure that layer is well-defined:
      if classifier.layer_names is None:
          raise ValueError("No layer names identified.")
  
      if isinstance(layer, int):
          if layer < 0 or layer >= len(classifier.layer_names):
              raise ValueError(
                  f"Layer index {layer} is outside of range (0 to {len(classifier.layer_names) - 1} included)."
              )
          self._layer_name = classifier.layer_names[layer]
      else:
          if layer not in classifier.layer_names:
              raise ValueError(
                  f"Layer name {layer} is not part of the graph."
              )
          self._layer_name = layer
  
file_path: adversarial-robustness-toolbox/art/defences/detector/evasion/binary_activation_detector.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Tuple, Union, TYPE_CHECKING
  import numpy
  from art.defences.detector.evasion.evasion_detector import EvasionDetector
label_desc: Use image node_id 1 to create a new BinaryActivationDetector object from inherited base classes: EvasionDetector with example: obj = BinaryActivationDetector(classifier, detector, layer)