docstr: Test the basic single GPU performance by comparing to the FGSM
  tutorial.
docstr_tok: ["Test","the","basic","single","GPU","performance","by","comparing","to","the","FGSM","tutorial","."]
code: def test_run_single_gpu_fgsm(self):
      """
      Test the basic single GPU performance by comparing to the FGSM
      tutorial.
      """
      from cleverhans_tutorials import mnist_tutorial_tf
  
      # Run the MNIST tutorial on a dataset of reduced size
      flags = {
          "train_start": 0,
          "train_end": 5000,
          "test_start": 0,
          "test_end": 333,
          "nb_epochs": 5,
          "testing": True,
      }
      report = mnist_tutorial_tf.mnist_tutorial(**flags)
  
      # Run the multi-gpu trainer for clean training
      flags.update(
          {
              "batch_size": 128,
              "adam_lrn": 0.001,
              "dataset": "mnist",
              "only_adv_train": False,
              "eval_iters": 1,
              "ngpu": 1,
              "fast_tests": False,
              "attack_type_train": "",
              "save_dir": None,
              "save_steps": 10000,
              "attack_nb_iter_train": None,
              "save": False,
              "model_type": "basic",
              "attack_type_test": "FGSM",
          }
      )
  
      flags.update({"adv_train": False})
      HParams = namedtuple("HParams", flags.keys())
  
      hparams = HParams(**flags)
      np.random.seed(42)
      tf.set_random_seed(42)
      with tf.variable_scope(None, "runner"):
          report_dict = run_trainer(hparams)
      report_2 = AccuracyReport()
      report_2.train_clean_train_clean_eval = report_dict["train"]
      report_2.clean_train_clean_eval = report_dict["test"]
      report_2.clean_train_adv_eval = report_dict["FGSM"]
  
      # Run the multi-gpu trainer for adversarial training
      flags.update({"adv_train": True, "attack_type_train": "FGSM"})
      HParams = namedtuple("HParams", flags.keys())
  
      hparams = HParams(**flags)
      np.random.seed(42)
      tf.set_random_seed(42)
      with tf.variable_scope(None, "runner"):
          report_dict = run_trainer(hparams)
      report_2.train_adv_train_clean_eval = report_dict["train"]
      report_2.adv_train_clean_eval = report_dict["test"]
      report_2.adv_train_adv_eval = report_dict["FGSM"]
  
      self.assertClose(
          report.train_clean_train_clean_eval,
          report_2.train_clean_train_clean_eval,
          atol=5e-2,
      )
      self.assertClose(
          report.clean_train_clean_eval,
          report_2.clean_train_clean_eval,
          atol=2e-2,
      )
      self.assertClose(
          report.clean_train_adv_eval,
          report_2.clean_train_adv_eval,
          atol=5e-2,
      )
      self.assertClose(
          report.train_adv_train_clean_eval,
          report_2.train_adv_train_clean_eval,
          atol=1e-1,
      )
      self.assertClose(
          report.adv_train_clean_eval,
          report_2.adv_train_clean_eval,
          atol=2e-2,
      )
      self.assertClose(
          report.adv_train_adv_eval,
          report_2.adv_train_adv_eval,
          atol=1e-1,
      )
  
file_path: cleverhans/cleverhans_v3.1.0/examples/multigpu_advtrain/test_run_multigpu.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from collections import namedtuple
  import unittest
  import numpy
  import tensorflow
  from cleverhans.utils import AccuracyReport
  from cleverhans.devtools.checks import CleverHansTest
  from run_multigpu import run_trainer
label_desc: Use image node_id 2 for calling the TestRunMultiGPU obj's underlying member method code with example usage: obj.test_run_single_gpu_fgsm() without return types