title: Tensorflow metrics with custom Estimator
body: <p>I have a convolutional neural network that I recently refactored to use Tensorflow's Estimator API, largely following <a href="https://github.com/Hvass-Labs/TensorFlow-Tutorials/blob/master/17_Estimator_API.ipynb" rel="nofollow noreferrer">this tutorial</a>. However, during training, the metrics I have added to the EstimatorSpec are not being displayed on Tensorboard and do not seem to be evaluated in tfdbg, despite the name scope and metrics being present in the graph written to Tensorboard. </p>
  
  <p>The relevant bits for the <code>model_fn</code> are as follows:</p>
  
  <pre><code> ...
  
   predictions = tf.placeholder(tf.float32, [num_classes], name="predictions")
  
   ...
  
   with tf.name_scope("metrics"):
      predictions_rounded = tf.round(predictions)
      accuracy = tf.metrics.accuracy(input_y, predictions_rounded, name='accuracy')
      precision = tf.metrics.precision(input_y, predictions_rounded, name='precision')
      recall = tf.metrics.recall(input_y, predictions_rounded, name='recall')
  
  if mode == tf.estimator.ModeKeys.PREDICT:
      spec = tf.estimator.EstimatorSpec(mode=mode,
                                        predictions=predictions)
  elif mode == tf.estimator.ModeKeys.TRAIN:
  
      ...
  
      # if we're doing softmax vs sigmoid, we have different metrics
      if cross_entropy == CrossEntropyType.SOFTMAX:
          metrics = {
              'accuracy': accuracy,
              'precision': precision,
              'recall': recall
          }
      elif cross_entropy == CrossEntropyType.SIGMOID:
          metrics = {
              'precision': precision,
              'recall': recall
          }
      else:
          raise NotImplementedError("Unrecognized cross entropy function: {}\t Available types are: SOFTMAX, SIGMOID".format(cross_entropy))
      spec = tf.estimator.EstimatorSpec(mode=mode,
                                        loss=loss,
                                        train_op=train_op,
                                        eval_metric_ops=metrics)
  else:
      raise NotImplementedError('ModeKey provided is not supported: {}'.format(mode))
  
  return spec
  </code></pre>
  
  <p>Anyone have any thoughts on why these aren't getting written? I'm using Tensorflow 1.7 and Python 3.5. I've tried adding them explicitly via <code>tf.summary.scalar</code>, and while they do get into Tensorboard that way, they're never updated after the first pass through the graph. </p>