2017-09-15 51 views
2

tf.metrics.precision_at_thresholds()有三个参数:labels, predictions, thresholds其中阈值是一个[0,1]之间的Python列表或阈值的元组。该函数然后返回“形状[len(阈值)]的浮动张量”,这对于自动绘制eval_metric_ops到张量板(因为我相信它们预计是标量)是有问题的。值将打印到控制台就好了,但我也想绘制tensorboard中的值。是否有任何调整可以绘制张量板中的值?在Tensorboard Tensorflow情节tf.metrics.precision_at_thresholds通过eval_metric_ops

回答

0

我目前的做法是创建一个单独的函数,它只需要列表中第一个元素的平均值。然而,我期待有一个比这更优雅的解决方案:

def metric_fn(labels, predictions, threshold): 
    precision, precision_op = tf.metrics.precision_at_thresholds(labels = labels, 
                predictions = predictions, 
                thresholds = threshold) 
    mean, op = tf.metrics.mean(precision[0]) 

    return mean, op