有没有人有使用带有 scalar_summary 的 SummaryWriter 的最小示例,以便在训练运行期间查看(比方说)交叉熵结果?
例子given in the documentation :
merged_summary_op = tf.merge_all_summaries()
summary_writer = tf.train.SummaryWriter('/tmp/mnist_logs', sess.graph_def)
total_step = 0
while training:
total_step += 1
session.run(training_op)
if total_step % 100 == 0:
summary_str = session.run(merged_summary_op)
summary_writer.add_summary(summary_str, total_step)
返回错误:TypeError: Fetch argument None of None has invalid type , must be a string or Tensor. (不能将 NoneType 转换为 Tensor 或 Operation。) 当我运行它时。
如果我添加:
tf.scalar_summary('cross entropy', cross_entropy)
在我的交叉熵计算之后的操作,然后我得到了错误:
InvalidArgumentError:您必须为占位符张量“Placeholder_2”提供 dtype float 的值
这表明我需要向
添加一个 feed_dictsummary_str = session.run(merged_summary_op)
调用,但我不清楚 feed_dict 应该包含什么....
最佳答案
feed_dict
应该包含您用于运行 training_op
的相同值。它基本上指定了要为其计算摘要的网络的输入值。
关于tensorflow - 在 Tensorflow 中,如何生成标量摘要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33943992/