class_docstr: A unittest class for testing the UniversalPerturbation attack.
class_docstr_tok: ["A","unittest","class","for","testing","the","UniversalPerturbation","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()
  
      # Attack
      up = UniversalPerturbation(
          tfc,
          max_iter=1,
          attacker="newtonfool",
          attacker_params={"max_iter": 5, "verbose": False},
          verbose=False,
      )
      x_train_adv = up.generate(self.x_train_mnist)
      self.assertTrue((up.fooling_rate >= 0.2) or not up.converged)
  
      x_test_adv = self.x_test_mnist + up.noise
      self.assertFalse((self.x_test_mnist == x_test_adv).all())
  
      train_y_pred = np.argmax(tfc.predict(x_train_adv), axis=1)
      test_y_pred = np.argmax(tfc.predict(x_test_adv), axis=1)
      self.assertFalse(
          (np.argmax(self.y_test_mnist, axis=1) == test_y_pred).all()
      )
      self.assertFalse(
          (np.argmax(self.y_train_mnist, axis=1) == train_y_pred).all()
      )
  
      # 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.universal_perturbation import UniversalPerturbation
  from art.estimators.classification.classifier import ClassifierMixin
  from art.estimators.classification.keras import KerasClassifier
  from art.estimators.estimator import BaseEstimator
  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 2 for calling the TestUniversalPerturbation obj's underlying member method code with example usage: obj.test_3_tensorflow_mnist() without return types