class_docstr: A unittest class for testing the ElasticNet attack.
class_docstr_tok: ["A","unittest","class","for","testing","the","ElasticNet","attack","."]
code: def test_3_tensorflow_iris(self):
      classifier, sess = get_tabular_classifier_tf()
  
      # Test untargeted attack
      attack = ElasticNet(
          classifier, targeted=False, max_iter=10, verbose=False
      )
      x_test_adv = attack.generate(self.x_test_iris)
      expected_x_test_adv = np.asarray(
          [0.84810126, 0.43320203, 0.70404345, 0.29160658]
      )
      np.testing.assert_array_almost_equal(
          x_test_adv[0, :], expected_x_test_adv, decimal=6
      )
      self.assertLessEqual(np.amax(x_test_adv), 1.0)
      self.assertGreaterEqual(np.amin(x_test_adv), 0.0)
  
      predictions_adv = np.argmax(
          classifier.predict(x_test_adv), axis=1
      )
      np.testing.assert_array_equal(
          predictions_adv,
          np.asarray(
              [
                  1,
                  2,
                  2,
                  2,
                  1,
                  1,
                  1,
                  2,
                  1,
                  2,
                  1,
                  1,
                  1,
                  2,
                  2,
                  2,
                  2,
                  2,
                  1,
                  1,
                  1,
                  1,
                  1,
                  1,
                  1,
                  2,
                  2,
                  2,
                  2,
                  1,
                  2,
                  1,
                  2,
                  1,
                  0,
                  1,
                  2,
                  1,
                  2,
                  0,
                  2,
                  2,
                  1,
                  1,
                  2,
              ]
          ),
      )
      accuracy = (
          1.0
          - np.sum(
              predictions_adv == np.argmax(self.y_test_iris, axis=1)
          )
          / self.y_test_iris.shape[0]
      )
      logger.info("EAD success rate on Iris: %.2f%%", (accuracy * 100))
  
      # Test targeted attack
      targets = random_targets(self.y_test_iris, nb_classes=3)
      attack = ElasticNet(
          classifier, targeted=True, max_iter=10, verbose=False
      )
      x_test_adv = attack.generate(self.x_test_iris, **{"y": targets})
      expected_x_test_adv = np.asarray(
          [0.88713187, 0.5239736, 0.49900988, 0.05677444]
      )
      np.testing.assert_array_almost_equal(
          x_test_adv[0, :], expected_x_test_adv, decimal=6
      )
      self.assertLessEqual(np.amax(x_test_adv), 1.0)
      self.assertGreaterEqual(np.amin(x_test_adv), 0.0)
  
      predictions_adv = np.argmax(
          classifier.predict(x_test_adv), axis=1
      )
      np.testing.assert_array_equal(
          predictions_adv,
          np.asarray(
              [
                  0,
                  0,
                  0,
                  2,
                  2,
                  2,
                  2,
                  2,
                  2,
                  2,
                  2,
                  2,
                  0,
                  2,
                  0,
                  0,
                  2,
                  2,
                  0,
                  2,
                  2,
                  2,
                  2,
                  2,
                  2,
                  0,
                  0,
                  0,
                  2,
                  0,
                  2,
                  2,
                  2,
                  2,
                  2,
                  0,
                  0,
                  0,
                  2,
                  2,
                  2,
                  2,
                  2,
                  0,
                  2,
              ]
          ),
      )
  
      accuracy = (
          np.sum(predictions_adv == np.argmax(targets, axis=1))
          / self.y_test_iris.shape[0]
      )
      logger.info(
          "Targeted EAD success rate on Iris: %.2f%%", (accuracy * 100)
      )
  
      # Close 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.elastic_net import ElasticNet
  from art.estimators.estimator import BaseEstimator
  from art.estimators.classification.classifier import ClassGradientsMixin
  from art.estimators.classification.keras import KerasClassifier
  from art.utils import random_targets, to_categorical
  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, master_seed
label_desc: Use image node_id 10 for calling the TestElasticNet obj's underlying member method code with example usage: obj.test_3_tensorflow_iris() without return types