class_docstr: Callback to perform membership inference attack on epoch end.
class_docstr_tok: ["Callback","to","perform","membership","inference","attack","on","epoch","end","."]
docstr: Initalizes the callback.
  
  Args:
    in_train: (in_training samples, in_training labels)
    out_train: (out_training samples, out_training labels)
    slicing_spec: slicing specification of the attack
    attack_types: a list of attacks, each of type AttackType
    tensorboard_dir: directory for tensorboard summary
    tensorboard_merge_classifiers: if true, plot different classifiers with
      the same slicing_spec and metric in the same figure
    is_logit: whether the result of model.predict is logit or probability
    batch_size: the batch size for model.predict
docstr_tok: ["Initalizes","the","callback",".","Args",":","in_train",":","(","in_training","samples",",","in_training","labels",")","out_train",":","(","out_training","samples",",","out_training","labels",")","slicing_spec",":","slicing","specification","of","the","attack","attack_types",":","a","list","of","attacks",",","each","of","type","AttackType","tensorboard_dir",":","directory","for","tensorboard","summary","tensorboard_merge_classifiers",":","if","true",",","plot","different","classifiers","with","the","same","slicing_spec","and","metric","in","the","same","figure","is_logit",":","whether","the","result","of","model.predict","is","logit","or","probability","batch_size",":","the","batch","size","for","model.predict"]
code: def __init__(
      self,
      in_train,
      out_train,
      slicing_spec: SlicingSpec = None,
      attack_types: Iterable[AttackType] = (
          AttackType.THRESHOLD_ATTACK,
      ),
      tensorboard_dir=None,
      tensorboard_merge_classifiers=False,
      is_logit=False,
      batch_size=32,
  ):
      """Initalizes the callback.
  
      Args:
        in_train: (in_training samples, in_training labels)
        out_train: (out_training samples, out_training labels)
        slicing_spec: slicing specification of the attack
        attack_types: a list of attacks, each of type AttackType
        tensorboard_dir: directory for tensorboard summary
        tensorboard_merge_classifiers: if true, plot different classifiers with
          the same slicing_spec and metric in the same figure
        is_logit: whether the result of model.predict is logit or probability
        batch_size: the batch size for model.predict
      """
      self._in_train_data, self._in_train_labels = in_train
      self._out_train_data, self._out_train_labels = out_train
      self._slicing_spec = slicing_spec
      self._attack_types = attack_types
      self._tensorboard_merge_classifiers = (
          tensorboard_merge_classifiers
      )
      self._is_logit = is_logit
      self._batch_size = batch_size
      if tensorboard_dir:
          if tensorboard_merge_classifiers:
              self._writers = {}
              for attack_type in attack_types:
                  self._writers[
                      attack_type.name
                  ] = tf.summary.create_file_writer(
                      os.path.join(
                          tensorboard_dir, "MI", attack_type.name
                      )
                  )
          else:
              self._writers = tf.summary.create_file_writer(
                  os.path.join(tensorboard_dir, "MI")
              )
          logging.info("Will write to tensorboard.")
      else:
          self._writers = None
  
file_path: privacy/tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/keras_evaluation.py
imports: import os
  from typing import Iterable
  from absl import logging
  import tensorflow
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import membership_inference_attack
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import AttackInputData
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import AttackType
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import get_flattened_attack_metrics
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.data_structures import SlicingSpec
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack.utils_tensorboard import write_results_to_tensorboard_tf2
  from tensorflow_privacy.privacy.privacy_tests.utils import log_loss
label_desc: Use image node_id 1 to create a new MembershipInferenceCallback object from inherited base classes: tf.keras.callbacks with example: obj = MembershipInferenceCallback(in_train, out_train, slicing_spec, attack_types, tensorboard_dir, tensorboard_merge_classifiers, is_logit, batch_size)