class_docstr: A unittest class for testing the ZOO attack.
class_docstr_tok: ["A","unittest","class","for","testing","the","ZOO","attack","."]
docstr: First test with the TensorFlowClassifier.
  :return:
docstr_tok: ["First","test","with","the","TensorFlowClassifier",".",":","return",":"]
code: def test_3_tensorflow_mnist(self):
      """
      First test with the TensorFlowClassifier.
      :return:
      """
      x_test_original = self.x_test_mnist.copy()
  
      # Build TensorFlowClassifier
      tfc, sess = get_image_classifier_tf()
  
      # Targeted attack
      zoo = ZooAttack(
          classifier=tfc,
          targeted=True,
          max_iter=30,
          binary_search_steps=8,
          batch_size=128,
          verbose=False,
      )
      params = {"y": random_targets(self.y_test_mnist, tfc.nb_classes)}
      x_test_mnist_adv = zoo.generate(self.x_test_mnist, **params)
      self.assertFalse((self.x_test_mnist == x_test_mnist_adv).all())
      self.assertLessEqual(np.amax(x_test_mnist_adv), 1.0)
      self.assertGreaterEqual(np.amin(x_test_mnist_adv), 0.0)
      target = np.argmax(params["y"], axis=1)
      y_pred_adv = np.argmax(tfc.predict(x_test_mnist_adv), axis=1)
      logger.debug("ZOO target: %s", target)
      logger.debug("ZOO actual: %s", y_pred_adv)
      logger.info(
          "ZOO success rate on MNIST: %.2f",
          (sum(target == y_pred_adv) / float(len(target))),
      )
  
      # Untargeted attack
      zoo = ZooAttack(
          classifier=tfc,
          targeted=False,
          max_iter=10,
          binary_search_steps=3,
          verbose=False,
      )
      x_test_mnist_adv = zoo.generate(self.x_test_mnist)
      # self.assertFalse((x_test == x_test_adv).all())
      self.assertLessEqual(np.amax(x_test_mnist_adv), 1.0)
      self.assertGreaterEqual(np.amin(x_test_mnist_adv), 0.0)
      y_pred = np.argmax(tfc.predict(self.x_test_mnist), axis=1)
      y_pred_adv = np.argmax(tfc.predict(x_test_mnist_adv), axis=1)
      logger.debug("ZOO actual: %s", y_pred_adv)
      logger.info(
          "ZOO success rate on MNIST: %.2f",
          (sum(y_pred != y_pred_adv) / float(len(y_pred))),
      )
  
      # 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,
      )
  
      # Check resize
      x_test_resized = zoo._resize_image(self.x_test_mnist, 64, 64)
      self.assertEqual(x_test_resized.shape, (1, 64, 64, 1))
  
      # Clean-up session
      if sess is not None:
          sess.close()
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import keras.backend
  import numpy
  from art.attacks.evasion.zoo import ZooAttack
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin
  from art.utils import random_targets
  from tests.utils import TestBase, get_image_classifier_kr, get_image_classifier_pt
  from tests.utils import get_image_classifier_tf, master_seed
  from tests.attacks.utils import backend_test_classifier_type_check_fail
label_desc: Use image node_id 3 for calling the TestZooAttack obj's underlying member method code with example usage: obj.test_3_tensorflow_mnist() without return types