(self, labels, logits)
return eval_hooks, eval_metrics_ops
lables: [batch]
        logits: [batch, num_classes]
lables: [batch]
        logits: [batch, num_classes]
lables : [ batch ] logits : [ batch num_classes ]
def get_eval_hooks(self, labels, logits):
    ''' lables: [batch]
        logits: [batch, num_classes]
    '''
    nclass = self.config['data']['task']['classes']['num']

    eval_hooks = []
    metric_tensor = {}
    with tf.variable_scope('metrics'):
      true_label = labels
      true_label_bool = tf.cast(labels, tf.bool)
      softmax = tf.nn.softmax(logits)
      pred_label = tf.argmax(softmax, -1)
      eval_metrics_ops = {
          'accuracy':
              tf.metrics.accuracy(
                  labels=true_label, predictions=pred_label, weights=None),
      }
      if nclass == 2:
        eval_metrics_ops.update({
            'auc':
                tf.metrics.auc(
                    labels=true_label,
                    predictions=softmax[:, -1],
                    num_thresholds=20,
                    curve='ROC',
                    summation_method='trapezoidal'),
            'precision':
                tf.metrics.precision(
                    labels=true_label, predictions=pred_label, weights=None),
            'recall':
                tf.metrics.recall(
                    labels=true_label, predictions=pred_label, weights=None),
            'tp':
                tf.metrics.true_positives(
                    labels=true_label, predictions=pred_label, weights=None),
            'fn':
                tf.metrics.false_negatives(
                    labels=true_label, predictions=pred_label, weights=None),
            'fp':
                tf.metrics.false_positives(
                    labels=true_label, predictions=pred_label, weights=None),
            'tn':
                tf.metrics.true_negatives(
                    labels=true_label, predictions=pred_label, weights=None),
            'pr_curve_eval':
                pr_summary.streaming_op(
                    name='pr_curve_eval',
                    labels=true_label_bool,
                    predictions=softmax[:, -1],
                    num_thresholds=50,
                    weights=None)
        })

    metric_tensor.update({key: val[0] for key, val in eval_metrics_ops.items()})
    metric_hook = tf.train.LoggingTensorHook(
        tensors=metric_tensor,
        every_n_iter=100,
        every_n_secs=None,
        at_end=False,
        formatter=None)
    eval_hooks.append(metric_hook)
    return eval_hooks, eval_metrics_ops
def get_eval_hooks ( self , labels , logits ) : nclass = self . config [ 'data' ] [ 'task' ] [ 'classes' ] [ 'num' ] eval_hooks = [ ] metric_tensor = { } with tf . variable_scope ( 'metrics' ) : true_label = labels true_label_bool = tf . cast ( labels , tf . bool ) softmax = tf . nn . softmax ( logits ) pred_label = tf . argmax ( softmax , - 1 ) eval_metrics_ops = { 'accuracy' : tf . metrics . accuracy ( labels = true_label , predictions = pred_label , weights = None ) , } if nclass == 2 : eval_metrics_ops . update ( { 'auc' : tf . metrics . auc ( labels = true_label , predictions = softmax [ : , - 1 ] , num_thresholds = 20 , curve = 'ROC' , summation_method = 'trapezoidal' ) , 'precision' : tf . metrics . precision ( labels = true_label , predictions = pred_label , weights = None ) , 'recall' : tf . metrics . recall ( labels = true_label , predictions = pred_label , weights = None ) , 'tp' : tf . metrics . true_positives ( labels = true_label , predictions = pred_label , weights = None ) , 'fn' : tf . metrics . false_negatives ( labels = true_label , predictions = pred_label , weights = None ) , 'fp' : tf . metrics . false_positives ( labels = true_label , predictions = pred_label , weights = None ) , 'tn' : tf . metrics . true_negatives ( labels = true_label , predictions = pred_label , weights = None ) , 'pr_curve_eval' : pr_summary . streaming_op ( name = 'pr_curve_eval' , labels = true_label_bool , predictions = softmax [ : , - 1 ] , num_thresholds = 50 , weights = None ) } ) metric_tensor . update ( { key : val [ 0 ] for key , val in eval_metrics_ops . items ( ) } ) metric_hook = tf . train . LoggingTensorHook ( tensors = metric_tensor , every_n_iter = 100 , every_n_secs = None , at_end = False , formatter = None ) eval_hooks . append ( metric_hook ) return eval_hooks , eval_metrics_ops