class_docstr: Tests for DP-enabled heads.
class_docstr_tok: ["Tests","for","DP-enabled","heads","."]
docstr: Tests that an Estimator built with a binary head works.
docstr_tok: ["Tests","that","an","Estimator","built","with","a","binary","head","works","."]
code: def testCreateTPUEstimatorSpec(self, n_classes):
      """Tests that an Estimator built with a binary head works."""
  
      train_features, train_labels = test_utils.make_input_data(
          256, n_classes
      )
      feature_columns = []
      for key in train_features:
          feature_columns.append(
              tf.feature_column.numeric_column(key=key)
          )
  
      head = head_lib._binary_logistic_or_multi_class_head(
          n_classes=n_classes,
          weight_column=None,
          label_vocabulary=None,
          loss_reduction=tf.compat.v1.losses.Reduction.NONE,
      )
      optimizer = DPGradientDescentGaussianOptimizer(
          learning_rate=0.5,
          l2_norm_clip=1.0,
          noise_multiplier=0.0,
          num_microbatches=2,
      )
      model_fn = make_model_fn(head, optimizer, feature_columns)
      classifier = estimator.Estimator(model_fn=model_fn)
  
      classifier.train(
          input_fn=test_utils.make_input_fn(
              train_features, train_labels, True
          ),
          steps=4,
      )
  
      test_features, test_labels = test_utils.make_input_data(
          64, n_classes
      )
      classifier.evaluate(
          input_fn=test_utils.make_input_fn(
              test_features, test_labels, False
          ),
          steps=4,
      )
  
      predict_features, predict_labels = test_utils.make_input_data(
          64, n_classes
      )
      classifier.predict(
          input_fn=test_utils.make_input_fn(
              predict_features, predict_labels, False
          )
      )
  
file_path: privacy/tensorflow_privacy/privacy/estimators/v1/head_test.py
imports: from absl.testing import parameterized
  import tensorflow
  from tensorflow_privacy.privacy.estimators import test_utils
  from tensorflow_privacy.privacy.estimators.v1 import head
  from tensorflow_privacy.privacy.optimizers.dp_optimizer import DPGradientDescentGaussianOptimizer
  from tensorflow_estimator.python.estimator import estimator
label_desc: Use image node_id 1 for calling the DPHeadTest obj's underlying member method code with example usage: obj.testCreateTPUEstimatorSpec(n_classes) without return types