class_docstr: A unittest class for testing the HopSkipJump attack.
class_docstr_tok: ["A","unittest","class","for","testing","the","HopSkipJump","attack","."]
code: def test_4_pytorch_iris(self):
      classifier = get_tabular_classifier_pt()
      x_test = self.x_test_iris.astype(np.float32)
  
      # Norm=2
      attack = HopSkipJump(
          classifier,
          targeted=False,
          max_iter=20,
          max_eval=100,
          init_eval=10,
          verbose=False,
      )
      x_test_adv = attack.generate(x_test)
      self.assertFalse((x_test == x_test_adv).all())
      self.assertTrue((x_test_adv <= 1).all())
      self.assertTrue((x_test_adv >= 0).all())
  
      preds_adv = np.argmax(classifier.predict(x_test_adv), axis=1)
      self.assertFalse(
          (np.argmax(self.y_test_iris, axis=1) == preds_adv).all()
      )
      acc = (
          np.sum(preds_adv == np.argmax(self.y_test_iris, axis=1))
          / self.y_test_iris.shape[0]
      )
      logger.info(
          "Accuracy on Iris with HopSkipJump adversarial examples: %.2f%%",
          (acc * 100),
      )
  
      # Norm=np.inf
      attack = HopSkipJump(
          classifier,
          targeted=False,
          max_iter=20,
          max_eval=100,
          init_eval=10,
          norm=np.Inf,
          verbose=False,
      )
      x_test_adv = attack.generate(x_test)
      self.assertFalse((x_test == x_test_adv).all())
      self.assertTrue((x_test_adv <= 1).all())
      self.assertTrue((x_test_adv >= 0).all())
  
      preds_adv = np.argmax(classifier.predict(x_test_adv), axis=1)
      self.assertFalse(
          (np.argmax(self.y_test_iris, axis=1) == preds_adv).all()
      )
      acc = (
          np.sum(preds_adv == np.argmax(self.y_test_iris, axis=1))
          / self.y_test_iris.shape[0]
      )
      logger.info(
          "Accuracy on Iris with HopSkipJump adversarial examples: %.2f%%",
          (acc * 100),
      )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import keras.backend
  import numpy
  from art.attacks.evasion.hop_skip_jump import HopSkipJump
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification import ClassifierMixin
  from art.utils import random_targets
  from tests.utils import TestBase
  from tests.utils import get_image_classifier_tf, get_image_classifier_kr, get_image_classifier_pt
  from tests.utils import get_tabular_classifier_pt, master_seed
  from tests.attacks.utils import backend_test_classifier_type_check_fail
label_desc: Use image node_id 6 for calling the TestHopSkipJump obj's underlying member method code with example usage: obj.test_4_pytorch_iris() without return types