跟随example,我想在训练过程中绘制值列表的直方图。
更具体地说,是在不同阈值下的f1分数。这是我了解如何在训练期间的各个时间绘制roc曲线的第一步。
但是 Tensorboard仅绘制了一个奇怪的输出(见下文)。
这是生成它的代码:
import tensorflow as tf
tf.reset_default_graph()
k = tf.placeholder(tf.float32)
t = tf.convert_to_tensor(
[
tf.cast(tf.greater(k, float(threshold)), tf.float32) * k / 10
for threshold in range(0, 100, 10)
]
)
tf.summary.histogram("greater_k", t)
sess = tf.Session()
writer = tf.summary.FileWriter("/tmp/histogram_example")
summaries = tf.summary.merge_all()
N = 10
for step in range(N):
summ, tt = sess.run([summaries, t], feed_dict={k: step})
writer.add_summary(summ, global_step=step)
print(tt)
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0.1 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.2 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.3 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.4 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.5 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.6 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.7 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
[0.8 0. 0. 0. 0. 0. 0. 0. 0. 0. ]
(tf 1.8 tb 1.5)