class_docstr: Training hook to perform membership inference attack on epoch end.
class_docstr_tok: ["Training","hook","to","perform","membership","inference","attack","on","epoch","end","."]
code: def end(self, session):
      results = run_attack_helper(
          self._estimator,
          self._in_train_input_fn,
          self._out_train_input_fn,
          self._in_train_labels,
          self._out_train_labels,
          self._in_train_sample_weights,
          self._out_train_sample_weights,
          self._slicing_spec,
          self._attack_types,
      )
      logging.info(results)
  
      (
          att_types,
          att_slices,
          att_metrics,
          att_values,
      ) = data_structures.get_flattened_attack_metrics(results)
      print("Attack result:")
      print(
          "\n".join(
              [
                  "  %s: %.4f" % (", ".join([s, t, m]), v)
                  for t, s, m, v in zip(
                      att_types, att_slices, att_metrics, att_values
                  )
              ]
          )
      )
  
      # Write to tensorboard if tensorboard_dir is specified
      global_step = self._estimator.get_variable_value("global_step")
      if self._writers is not None:
          utils_tensorboard.write_results_to_tensorboard(
              results,
              self._writers,
              global_step,
              self._tensorboard_merge_classifiers,
          )
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/tf_estimator_evaluation.py
imports: import os
  from typing import Iterable, Optional
  from absl import logging
  import numpy
  import tensorflow
  from tensorflow import estimator
  from tensorflow_privacy.privacy.privacy_tests import utils
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import data_structures
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import membership_inference_attack
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import utils_tensorboard
label_desc: Use image node_id 2 for calling the MembershipInferenceTrainingHook obj's underlying member method code with example usage: obj.end(session) without return types