特定分支的摘要
Summary for the a specific branch
我有一个张量流图,它有一个复杂的训练损失函数,但一个更简单的评估损失函数(它们共享祖先)。本质上是这样
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 抱怨缺少占位符的值。
据我了解你的问题,总结一个具体的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。
希望对您有所帮助!
我有一个张量流图,它有一个复杂的训练损失函数,但一个更简单的评估损失函数(它们共享祖先)。本质上是这样
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 抱怨缺少占位符的值。
据我了解你的问题,总结一个具体的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。
希望对您有所帮助!