首先检查图中的tf.placeholder(),你在sess.run的时候是否feed满足dtype和shape的数据。如果你这两项都没错的话,那么你极有可能犯了重命名的错误,这里指的是使用占位符生成的变量和图中某个图操作节点的名称相同,也会报这个错误,例:
pred = tf.placeholder(tf.int64, shape = None, name='img_input')
gt = tf.placeholder(tf.int64, shape = None, name='label_input')
#print(pred_.name)
#print(gt_.name)
pred = tf.reshape(pred_,[-1])
gt = tf.reshape(gt_,[-1])
这样就导致了代码出错。
解决办法:
pred_ = tf.placeholder(tf.int64, shape = None, name='img_input')
gt_ = tf.placeholder(tf.int64, shape = None, name='label_input')
#print(pred_.name)
#print(gt_.name)
pred = tf.reshape(pred_,[-1])
gt = tf.reshape(gt_,[-1])
将占位符pred和gt变换名称即可。很坑人的一个小问题,很小但是很气人!!!