特定分支的摘要

时间:2017-12-07 18:43:53

标签: tensorflow tensorboard

我有一个张量流图,它具有复杂的训练损失函数,但更简单的一个用于评估(它们共享祖先)。基本上这个

train_op = ... (needs more things in feed_dict etc.)
acc = .... (just needs one value for placeholer)

为了更好地了解正在发生的事情,我添加了摘要。但是打电话给

merged = tf.summary.merge_all()

然后

(summ, acc) = session.run([merged, acc_eval], feed_dict={..})

tensorflow抱怨缺少占位符的值。

1 个答案:

答案 0 :(得分:1)

据我了解你的问题,要总结一个特定的tensorflow操作,你应该专门运行它。

例如:

# define accuracy ops
correct_prediction = tf.equal(tf.argmax(Y, axis=1), tf.argmax(Y_labels, axis=1))  
accuracy = tf.reduce_mean(tf.cast(correct_prediction, dtype=tf.float32))  

# summary_accuracy is the Summary protocol buffer you need to run, 
# instead of merge_all(), if you want to summary specific ops
summary_accuracy = tf.summary.scalar('testing_accuracy', accuracy) 

# define writer file
sess.run(tf.global_variables_initializer())
test_writer = tf.summary.FileWriter('log/test', sess.graph)

(summ, acc) = sess.run([summary_accuracy, accuracy], feed_dict={..})
test_writer.add_summary(summ)

此外,您可以使用tf.summary.merge()which is documented here 希望这有帮助!