用张量板

时间:2017-05-16 08:32:12

标签: tensorflow tensorboard

myplot: accuracy

运行具有张量流的NN模型,我想在训练集和测试集上绘制准确度分数。然而,情节张量板显示我看起来很奇怪:那里只有一个“准确性”标签,它在同一个数字上绘制了两个分数。所以基本上,x轴上的每一步都有两个连接在一起的点。如何在该图上分别绘制两条线(训练精度和测试精度)?

以下是我的代码片段:

loss_summary = tf.summary.scalar('loss', loss) acc_summary = tf.summary.scalar('accuracy', accuracy)

summary_loss, summary_acc_train = sess.run([loss_summary, acc_summary], feed_dict={X: X_train, y: y_train}) summary_acc_test = sess.run([acc_summary], feed_dict={X: X_test, y: y_test})

summary_writer.add_summary(summary_loss, epoch) summary_writer.add_summary(summary_acc_train, epoch) summary_writer.add_summary(summary_acc_test, epoch)

1 个答案:

答案 0 :(得分:3)

You need to create two different summary writers:

train_summary_writer = tf.summary.FileWriter(os.path.join(SUMMARIES_DIR, "train"), sess.graph)
validation_summary_writer = tf.summary.FileWriter(os.path.join(SUMMARIES_DIR, "validation"), sess.graph)

 ...

train_summary_writer.add_summary(summary_loss, epoch)
train_summary_writer.add_summary(summary_acc_train, epoch)
validation_summary_writer.add_summary(summary_acc_test, epoch)