tensorflow: Cannot get TensorBoard example working
Here’s my code:
merged_summary_op = tf.merge_all_summaries()
summary_writer = tf.train.SummaryWriter('/tmp/mnist_logs', sess.graph_def)
for i in range(200):
batch = mnist.train.next_batch(50)
sess.run(train_step, feed_dict={x: batch[0], y_: batch[1])
if i % 100 == 0:
train_accuracy = sess.run(train_step, feed_dict={x: batch[0], y_: batch[1]})
summary_str = sess.run(merged_summary_op, feed_dict={x: batch[0], y_: batch[1]})
summary_writer.add_summary(summary_str, i)
but got this error at line sess.run(merged_summary_op, ...)
InvalidArgumentError Traceback (most recent call last)
<ipython-input-39-f56ad86fef0b> in <module>()
----> sess.run(merged_summary_op, feed_dict={x: batch[0], y_: batch[1]})
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict)
343
344 # Run request and get response.
--> 345 results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
346
347 # User may have fetched the same tensor multiple times, but we
/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.pyc in _do_run(self, target_list, fetch_list, feed_dict)
417 # pylint: disable=protected-access
418 raise errors._make_specific_exception(node_def, op, e.error_message,
--> 419 e.code)
420 # pylint: enable=protected-access
421 raise e_type, e_value, e_traceback
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float
The error message you must feed a value for placeholder tensor
doesn’t make much sense. The line above that with similar structure ran just fine.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 18 (2 by maintainers)
Links to this issue
Commits related to this issue
- Update README.md (#225) * Update README.md Added alternative way to install bazel. Because people have been facing problem and by mistake they are downloading the latest version. * Update READM... — committed to tarasglek/tensorflow by prakhar21 8 years ago
- [SYCL] Disable transpose for complex type (#225) — committed to codeplaysoftware/tensorflow by Rbiessy 6 years ago
- Introduce prefetch op: affine -> std -> llvm intrinsic Introduce affine.prefetch: op to prefetch using a multi-dimensional subscript on a memref; similar to affine.load but has no effect on semantics... — committed to tensorflow/tensorflow by bondhugula 5 years ago
I was getting the same error although my code looked similar to the one above. I’m using the interactive Jupyter Notebook environment, and I figured out that shutting down and restarting the notebook somehow solved my problem.
same error, can confirm mine was also a jupyter notebook problem. I think this arises when running the graph definition more than once (there are all sorts of problems with this!).
I had similar issues with jupyter notebooks and discovered that explicitly flushing and closing the summary writer helped.
I faced same problem with Jupyter notebook. The reason is not clear yet. But I agree with achristensen56-san’s comment.
If I run scripts more than 2 times, including # placeholder, I faced same issue.
Unfortunatelly. hblasins-san’s method didn’t work well in my case.
You don’t need use Jupyter’s restart. (it is stressful) With executing tf.reset_default_graph(), you can start your session from graph definition.
This was written by Guillermo-san in stackoverflow. https://stackoverflow.com/questions/39356714/using-tensorboard-with-jupyter-notebooks
Just Kernel:Restart & Run All