class_docstr: A unittest class for testing the ZOO attack.
class_docstr_tok: ["A","unittest","class","for","testing","the","ZOO","attack","."]
docstr: Third test with the PyTorchClassifier.
  :return:
docstr_tok: ["Third","test","with","the","PyTorchClassifier",".",":","return",":"]
code: def test_4_pytorch_mnist(self):
      """
      Third test with the PyTorchClassifier.
      :return:
      """
      # Build PyTorchClassifier
      ptc = get_image_classifier_pt()
  
      # Get MNIST
      x_test_mnist = np.swapaxes(self.x_test_mnist, 1, 3).astype(
          np.float32
      )
      x_test_original = x_test_mnist.copy()
  
      # First attack
      # zoo = ZooAttack(classifier=ptc, targeted=True, max_iter=10, binary_search_steps=10, verbose=False)
      # params = {'y': random_targets(self.y_test, ptc.nb_classes)}
      # x_test_adv = zoo.generate(x_test, **params)
      # self.assertFalse((x_test == x_test_adv).all())
      # self.assertLessEqual(np.amax(x_test_adv), 1.0)
      # self.assertGreaterEqual(np.amin(x_test_adv), 0.0)
      # target = np.argmax(params['y'], axis=1)
      # y_pred_adv = np.argmax(ptc.predict(x_test_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))))
  
      # Second attack
      zoo = ZooAttack(
          classifier=ptc,
          targeted=False,
          learning_rate=1e-2,
          max_iter=10,
          binary_search_steps=3,
          abort_early=False,
          use_resize=False,
          use_importance=False,
          verbose=False,
      )
      x_test_mnist_adv = zoo.generate(x_test_mnist)
      self.assertLessEqual(np.amax(x_test_mnist_adv), 1.0)
      self.assertGreaterEqual(np.amin(x_test_mnist_adv), 0.0)
  
      # print(x_test[0, 0, 14, :])
      # print(x_test_adv[0, 0, 14, :])
      # print(np.amax(x_test - x_test_adv))
      # x_test_adv_expected = []
  
      # Check that x_test has not been modified by attack and classifier
      self.assertAlmostEqual(
          float(np.max(np.abs(x_test_original - x_test_mnist))),
          0.0,
          delta=0.00001,
      )
  
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 5 for calling the TestZooAttack obj's underlying member method code with example usage: obj.test_4_pytorch_mnist() without return types