1. 首先检查自己feed给tensor的数据类型与大小与placeholder所得到的tensor的是否相同,如果不同就改成相同的,如果相同,请看下面:
2. 原文链接:http://www.itkeyword.com/doc/7197603979214654287/tensorflow-issue-with-placeholder-and-summaries
The problem here is that some of the summaries in your graph—collected by tf.merge_all_summaries()— depend on your placeholders. For example, the code in cifar10.py creates summaries for various activations at each step, which depend on the training example used.
The solution is to feed the same training batch when you evaluate summary_op:
if step % 100 == 0:
summary_str = sess.run(summary_op, feed_dict={
images: image[offset:(offset + batch_size)],
images2: image_p[offset:(offset + batch_size)],
labels: 1.0 * label[offset:(offset + batch_size)]})
While this gives the smallest modification to your original code, it is slightly inefficient, because it will re-execute the training step every 100 steps. The best way to address this (although it will require some restructuring of your training loop) is to fetch the summaries in the same call to sess.run() that performs a training step:
if step % 100 == 0:
_, loss_value, summary_str = sess.run([train_op, loss, summary_op], feed_dict={
images: image[offset:(offset + batch_size)],
images2: image_p[offset:(offset + batch_size)],
labels: 1.0 * label[offset:(offset + batch_size)]})
本文探讨了在使用TensorFlow时,placeholder与summary操作可能导致的问题,并提供了详细的解决方案。建议在评估summary_op时,使用相同的训练批次数据,以确保数据一致性。更优的做法是在执行训练步骤的同时获取summary,以提高效率。

1604

被折叠的 条评论
为什么被折叠?



