2017-09-15 50 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