2
votes

I am trying to generate the graph for MNIST beginner tutorial but is getting the following error. For some reason, merged_summary_op object is 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.)

I think I am missing a step here. I launched the session first and then running the statement:

merged_summary_op = tf.merge_all_summaries()
1

1 Answers

7
votes

I had the same error.

In my case, adding at least one tf.scalar_summary() before calling tf.merge_all_summaries() solved the problem.

For example,

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

I hope this snippet helps you.