class_docstr: This class implements a classifier with the TensorFlow framework.
class_docstr_tok: ["This","class","implements","a","classifier","with","the","TensorFlow","framework","."]
docstr: Initialization specific to TensorFlow models implementation.
  
  :param input_ph: The input placeholder.
  :param output: The output layer of the model. This can be logits, probabilities or anything else. Logits
         output should be preferred where possible to ensure attack efficiency.
  :param labels_ph: The labels placeholder of the model. This parameter is necessary when training the model and
         when computing gradients w.r.t. the loss function.
  :param train: The train tensor for fitting, including an optimizer. Use this parameter only when training the
         model.
  :param loss: The loss function for which to compute gradients. This parameter is necessary when training the
         model and when computing gradients w.r.t. the loss function.
  :param learning: The placeholder to indicate if the model is training.
  :param sess: Computation session.
  :param channels_first: Set channels first or last.
  :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
         maximum values allowed for features. If floats are provided, these will be used as the range of all
         features. If arrays are provided, each value will be considered the bound for a feature, thus
         the shape of clip values needs to match the total number of features.
  :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
  :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
  :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
         used for data preprocessing. The first value will be subtracted from the input. The input will then
         be divided by the second one.
  :param feed_dict: A feed dictionary for the session run evaluating the classifier. This dictionary includes all
                    additionally required placeholders except the placeholders defined in this class.
docstr_tok: ["Initialization","specific","to","TensorFlow","models","implementation",".",":","param","input_ph",":","The","input","placeholder",".",":","param","output",":","The","output","layer","of","the","model",".","This","can","be","logits",",","probabilities","or","anything","else",".","Logits","output","should","be","preferred","where","possible","to","ensure","attack","efficiency",".",":","param","labels_ph",":","The","labels","placeholder","of","the","model",".","This","parameter","is","necessary","when","training","the","model","and","when","computing","gradients","w.r.t",".","the","loss","function",".",":","param","train",":","The","train","tensor","for","fitting",",","including","an","optimizer",".","Use","this","parameter","only","when","training","the","model",".",":","param","loss",":","The","loss","function","for","which","to","compute","gradients",".","This","parameter","is","necessary","when","training","the","model","and","when","computing","gradients","w.r.t",".","the","loss","function",".",":","param","learning",":","The","placeholder","to","indicate","if","the","model","is","training",".",":","param","sess",":","Computation","session",".",":","param","channels_first",":","Set","channels","first","or","last",".",":","param","clip_values",":","Tuple","of","the","form","`","(","min",",","max",")","`","of","floats","or","`","np.ndarray","`","representing","the","minimum","and","maximum","values","allowed","for","features",".","If","floats","are","provided",",","these","will","be","used","as","the","range","of","all","features",".","If","arrays","are","provided",",","each","value","will","be","considered","the","bound","for","a","feature",",","thus","the","shape","of","clip","values","needs","to","match","the","total","number","of","features",".",":","param","preprocessing_defences",":","Preprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","postprocessing_defences",":","Postprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","preprocessing",":","Tuple","of","the","form","`","(","subtrahend",",","divisor",")","`","of","floats","or","`","np.ndarray","`","of","values","to","be","used","for","data","preprocessing",".","The","first","value","will","be","subtracted","from","the","input",".","The","input","will","then","be","divided","by","the","second","one",".",":","param","feed_dict",":","A","feed","dictionary","for","the","session","run","evaluating","the","classifier",".","This","dictionary","includes","all","additionally","required","placeholders","except","the","placeholders","defined","in","this","class","."]
code: def __init__(
      self,
      input_ph: "tf.Placeholder",
      output: "tf.Tensor",
      labels_ph: Optional["tf.Placeholder"] = None,
      train: Optional["tf.Tensor"] = None,
      loss: Optional["tf.Tensor"] = None,
      learning: Optional["tf.Placeholder"] = None,
      sess: Optional["tf.Session"] = None,
      channels_first: bool = False,
      clip_values: Optional["CLIP_VALUES_TYPE"] = None,
      preprocessing_defences: Union[
          "Preprocessor", List["Preprocessor"], None
      ] = None,
      postprocessing_defences: Union[
          "Postprocessor", List["Postprocessor"], None
      ] = None,
      preprocessing: "PREPROCESSING_TYPE" = (0.0, 1.0),
      feed_dict: Optional[Dict[Any, Any]] = None,
  ) -> None:
      """
      Initialization specific to TensorFlow models implementation.
  
      :param input_ph: The input placeholder.
      :param output: The output layer of the model. This can be logits, probabilities or anything else. Logits
             output should be preferred where possible to ensure attack efficiency.
      :param labels_ph: The labels placeholder of the model. This parameter is necessary when training the model and
             when computing gradients w.r.t. the loss function.
      :param train: The train tensor for fitting, including an optimizer. Use this parameter only when training the
             model.
      :param loss: The loss function for which to compute gradients. This parameter is necessary when training the
             model and when computing gradients w.r.t. the loss function.
      :param learning: The placeholder to indicate if the model is training.
      :param sess: Computation session.
      :param channels_first: Set channels first or last.
      :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
             maximum values allowed for features. If floats are provided, these will be used as the range of all
             features. If arrays are provided, each value will be considered the bound for a feature, thus
             the shape of clip values needs to match the total number of features.
      :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
      :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
      :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
             used for data preprocessing. The first value will be subtracted from the input. The input will then
             be divided by the second one.
      :param feed_dict: A feed dictionary for the session run evaluating the classifier. This dictionary includes all
                        additionally required placeholders except the placeholders defined in this class.
      """
      # pylint: disable=E0401
      import tensorflow.compat.v1 as tf
  
      super().__init__(
          model=None,
          clip_values=clip_values,
          channels_first=channels_first,
          preprocessing_defences=preprocessing_defences,
          postprocessing_defences=postprocessing_defences,
          preprocessing=preprocessing,
      )
  
      self.nb_classes = int(output.get_shape()[-1])
      self._input_shape = tuple(input_ph.get_shape().as_list()[1:])
      self._input_ph = input_ph
      self._output = output
      self._labels_ph = labels_ph
      self._train = train
      self._loss = loss
      self._learning = learning
      if feed_dict is None:
          self._feed_dict = {}
      else:
          self._feed_dict = feed_dict
  
      # Assign session
      if sess is None:  # pragma: no cover
          raise ValueError("A session cannot be None.")
      self._sess = sess
  
      # Get the internal layers
      self._layer_names = self._get_layers()
  
      # Get the loss gradients graph
      if self._loss is not None:
          self._loss_grads = tf.gradients(self._loss, self.input_ph)[0]
  
      # Check if the loss function requires as input index labels instead of one-hot-encoded labels
      if self.labels_ph is not None and len(self.labels_ph.shape) == 1:
          self._reduce_labels = True
      else:
          self._reduce_labels = False
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import random
  import shutil
  import time
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union, TYPE_CHECKING
  from tqdm.auto import tqdm
  import numpy
  import six
  from art import config
  from art.estimators.classification.classifier import ClassGradientsMixin, ClassifierMixin
  from art.estimators.tensorflow import TensorFlowEstimator, TensorFlowV2Estimator
  from art.utils import check_and_transform_label_format
label_desc: Use image node_id 1 to create a new TensorFlowClassifier object from inherited base classes: ClassGradientsMixin, ClassifierMixin, TensorFlowEstimator with example: obj = TensorFlowClassifier(input_ph, output, labels_ph, train, loss, learning, sess, channels_first, clip_values, preprocessing_defences, postprocessing_defences, preprocessing, feed_dict)