class_docstr: A unittest class for testing the KnockoffNets attack.
docstr: Third test with the PyTorchClassifier.
  :return:
docstr_tok: ["Third","test","with","the","PyTorchClassifier",".",":","return",":"]
code: def test_5_pytorch_classifier(self):
      """
      Third test with the PyTorchClassifier.
      :return:
      """
      self.x_train_mnist = np.reshape(
          self.x_train_mnist, (self.x_train_mnist.shape[0], 1, 28, 28)
      ).astype(np.float32)
  
      # Build PyTorchClassifier
      victim_ptc = get_image_classifier_pt()
  
      # Create the thieved classifier
      thieved_ptc = get_image_classifier_pt(load_init=False)
  
      # Create random attack
      attack = KnockoffNets(
          classifier=victim_ptc,
          batch_size_fit=BATCH_SIZE,
          batch_size_query=BATCH_SIZE,
          nb_epochs=NB_EPOCHS,
          nb_stolen=NB_STOLEN,
          sampling_strategy="random",
          verbose=False,
      )
  
      thieved_ptc = attack.extract(
          x=self.x_train_mnist, thieved_classifier=thieved_ptc
      )
  
      victim_preds = np.argmax(
          victim_ptc.predict(x=self.x_train_mnist), axis=1
      )
      thieved_preds = np.argmax(
          thieved_ptc.predict(x=self.x_train_mnist), axis=1
      )
      acc = np.sum(victim_preds == thieved_preds) / len(victim_preds)
  
      self.assertGreater(acc, 0.3)
  
      # Create adaptive attack
      attack = KnockoffNets(
          classifier=victim_ptc,
          batch_size_fit=BATCH_SIZE,
          batch_size_query=BATCH_SIZE,
          nb_epochs=NB_EPOCHS,
          nb_stolen=NB_STOLEN,
          sampling_strategy="adaptive",
          reward="all",
          verbose=False,
      )
      thieved_ptc = attack.extract(
          x=self.x_train_mnist,
          y=self.y_train_mnist,
          thieved_classifier=thieved_ptc,
      )
  
      victim_preds = np.argmax(
          victim_ptc.predict(x=self.x_train_mnist), axis=1
      )
      thieved_preds = np.argmax(
          thieved_ptc.predict(x=self.x_train_mnist), axis=1
      )
      acc = np.sum(victim_preds == thieved_preds) / len(victim_preds)
  
      self.assertGreater(acc, 0.4)
  
      self.x_train_mnist = np.reshape(
          self.x_train_mnist, (self.x_train_mnist.shape[0], 28, 28, 1)
      ).astype(np.float32)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  import keras.backend
  from art.attacks.extraction.knockoff_nets import KnockoffNets
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassifierMixin
  from tests.utils import TestBase, master_seed
  from tests.utils import get_image_classifier_tf, get_image_classifier_kr, get_image_classifier_pt
  from tests.utils import get_tabular_classifier_tf, get_tabular_classifier_kr, get_tabular_classifier_pt
  from tests.attacks.utils import backend_test_classifier_type_check_fail
label_desc: Use image node_id 5 for calling the TestKnockoffNets obj's underlying member method code with example usage: obj.test_5_pytorch_classifier() without return types