code: def test_3_tensorflow_mnist(self):
      x_test_original = self.x_test_mnist.copy()
  
      # Create basic CNN on MNIST using TensorFlow
      classifier, sess = get_image_classifier_tf()
  
      scores = get_labels_np_array(
          classifier.predict(self.x_train_mnist)
      )
      accuracy = (
          np.sum(
              np.argmax(scores, axis=1)
              == np.argmax(self.y_train_mnist, axis=1)
          )
          / self.n_train
      )
      logger.info(
          "[TF, MNIST] Accuracy on training set: %.2f%%",
          (accuracy * 100),
      )
  
      scores = get_labels_np_array(
          classifier.predict(self.x_test_mnist)
      )
      accuracy = (
          np.sum(
              np.argmax(scores, axis=1)
              == np.argmax(self.y_test_mnist, axis=1)
          )
          / self.n_train
      )
      logger.info(
          "[TF, MNIST] Accuracy on test set: %.2f%%", (accuracy * 100)
      )
  
      # targeted
      # Generate random target classes
      nb_classes = np.unique(
          np.argmax(self.y_test_mnist, axis=1)
      ).shape[0]
      targets = np.random.randint(nb_classes, size=self.n_test)
      while (targets == np.argmax(self.y_test_mnist, axis=1)).any():
          targets = np.random.randint(nb_classes, size=self.n_test)
  
      # Perform attack
      df = SaliencyMapMethod(
          classifier, theta=1, batch_size=100, verbose=False
      )
      x_test_adv = df.generate(
          self.x_test_mnist, y=to_categorical(targets, nb_classes)
      )
  
      self.assertFalse((self.x_test_mnist == x_test_adv).all())
      self.assertFalse((0.0 == x_test_adv).all())
  
      y_pred = get_labels_np_array(classifier.predict(x_test_adv))
      self.assertFalse((self.y_test_mnist == y_pred).all())
  
      accuracy = (
          np.sum(
              np.argmax(y_pred, axis=1)
              == np.argmax(self.y_test_mnist, axis=1)
          )
          / self.n_test
      )
      logger.info(
          "Accuracy on adversarial examples: %.2f%%", (accuracy * 100)
      )
  
      # untargeted
      df = SaliencyMapMethod(
          classifier, theta=1, batch_size=100, verbose=False
      )
      x_test_adv = df.generate(self.x_test_mnist)
  
      self.assertFalse((self.x_test_mnist == x_test_adv).all())
      self.assertFalse((0.0 == x_test_adv).all())
  
      y_pred = get_labels_np_array(classifier.predict(x_test_adv))
      self.assertFalse((self.y_test_mnist == y_pred).all())
  
      accuracy = (
          np.sum(
              np.argmax(y_pred, axis=1)
              == np.argmax(self.y_test_mnist, axis=1)
          )
          / self.n_test
      )
      logger.info(
          "Accuracy on adversarial examples: %.2f%%", (accuracy * 100)
      )
  
      # Check that x_test has not been modified by attack and classifier
      self.assertAlmostEqual(
          float(np.max(np.abs(x_test_original - self.x_test_mnist))),
          0.0,
          delta=0.00001,
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  from art.attacks.evasion.saliency_map import SaliencyMapMethod
  from art.estimators.classification.classifier import ClassGradientsMixin
  from art.estimators.classification.keras import KerasClassifier
  from art.estimators.estimator import BaseEstimator
  from art.utils import get_labels_np_array, to_categorical
  from tests.attacks.utils import backend_test_classifier_type_check_fail
  from tests.utils import TestBase, get_image_classifier_kr, get_image_classifier_pt, get_image_classifier_tf, get_tabular_classifier_kr, get_tabular_classifier_pt, get_tabular_classifier_tf
label_desc: Use image node_id 3 for calling the TestSaliencyMap obj's underlying member method code with example usage: obj.test_3_tensorflow_mnist() without return types