You must feed a value for placeholder tensor 'Placeholder_1' with dtype float and shape [?,10]

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)]})

猜你喜欢

转载自blog.csdn.net/Summer_And_Opencv/article/details/82691972