from tensorflow.python.ops import logging_ops

      self._add_hidden_layer_summary(net, "hiddenlayer_%d" % layer_id)
    logit = layers.legacy_fully_connected(
        net,
        self._num_label_columns(),
        weight_collections=[self._dnn_weight_collection],
        bias_collections=[self._dnn_weight_collection],
        name="dnn_logit")
    self._add_hidden_layer_summary(logit, "dnn_logit")
    return logit

  def _add_hidden_layer_summary(self, value, tag):
    # TODO(zakaria): Move this code to tf.learn and add test.
    logging_ops.scalar_summary("%s:fraction_of_zero_values" % tag,
                               nn.zero_fraction(value))
    logging_ops.histogram_summary("%s:activation" % tag, value)

  def _linear_logits(self, features):
    logits, _, _ = layers.weighted_sum_from_feature_columns(
        columns_to_tensors=features,
        feature_columns=self._get_linear_feature_columns(),
        num_outputs=self._num_label_columns(),
        weight_collections=[self._linear_weight_collection],
        name="linear")
    return logits

  def _get_feature_dict(self, features):
    if isinstance(features, dict):
      return features
