当先锋百科网

首页 1 2 3 4 5 6 7

您可以重用accurity节点,但需要使用两个不同的summarywriter,一个用于训练运行,另一个用于测试数据。此外,还必须为变量指定精度的标量摘要。accuracy_summary = tf.scalar_summary("Training Accuracy", accuracy)

tf.scalar_summary("SomethingElse", foo)

summary_op = tf.merge_all_summaries()

summaries_dir = '/me/mydir/'

train_writer = tf.train.SummaryWriter(summaries_dir + '/train', sess.graph)

test_writer = tf.train.SummaryWriter(summaries_dir + '/test')

然后在你的训练循环中,你进行正常的训练,并将你的总结记录在train_writer上。此外,每100次迭代在测试集上运行一次图形,并使用测试写入程序仅记录精度摘要。# Record train set summaries, and train

summary, _ = sess.run([summary_op, train_step], feed_dict=...)

train_writer.add_summary(summary, n)

if n % 100 == 0: # Record summaries and test-set accuracy

summary, acc = sess.run([accuracy_summary, accuracy], feed_dict=...)

test_writer.add_summary(summary, n)

print('Accuracy at step %s: %s' % (n, acc))

然后,您可以将TensorBoard指向父目录(summaries_dir),它将加载这两个数据集。