您可以重复使用准确性节点,但是需要使用两个不同的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次迭代就在测试集上运行图形,并仅使用test_writer记录准确性摘要。
# Record train set summaries, and trainsummary, _ = 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),它将加载两个数据集。
也可以在TensorFlow
HowTo的https://www.tensorflow.org/versions/r0.11/how_tos/summaries_and_tensorboard/index.html中找到
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)