合并tensorboard的摘要时出错

时间:2015-11-18 06:01:17

标签: tensorflow tensorboard

我正在尝试为MNIST初学者教程生成图表,但是收到以下错误。出于某种原因,merged_summary_op对象为None。

Traceback (most recent call last):
  File "mnist1.py", line 48, in <module>
    summary_str = sess.run(merged_summary_op)
  File "/home/vagrant/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 307, in run
    % (subfetch, fetch, type(subfetch), e.message))
TypeError: Fetch argument None of None has invalid type <type 'NoneType'>, must be a string or Tensor. (Can not convert a NoneType into a Tensor or Operation.)

我想我在这里错过了一步。我首先启动了会话,然后运行语句:

merged_summary_op = tf.merge_all_summaries()

1 个答案:

答案 0 :(得分:7)

我遇到了同样的错误。

就我而言,在调用tf.scalar_summary()之前添加至少一个tf.merge_all_summaries()可以解决问题。

例如,

cross_entropy = -tf.reduce_sum(y_*tf.log(y))
tf.scalar_summary("cross_entropy", cross_entropy)
merged_summary_op = tf.merge_all_summaries()

我希望这段代码可以帮助您。