您的位置:首页 > 产品设计 > UI/UE

Tensorflow报错之一:InvalidArgumentError: You must feed a value for placeholder tensor 'inputs/x_input'

2018-03-03 11:38 3395 查看

D:\program\anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py in __exit__(self, type_arg, value_arg, traceback_arg)
472             compat.as_text(c_api.TF_Message(self.status.status)),
--> 473             c_api.TF_GetCode(self.status.status))
474     # Delete the underlying status object from memory otherwise it stays alive

InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype float and shape [?,1]
[[Node: Placeholder_1 = Placeholder[dtype=DT_FLOAT, shape=[?,1], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

During handling of the above exception, another exception occurred:

InvalidArgumentErrorTraceback (most recent call last)
<ipython-input-71-abd8654a9e35> in <module>()
66     tf.global_variables_initializer().run()
67     for i in range(TRAINING_STEPS):
---> 68         sess.run(train_op, feed_dict={x: data, y_: label})
69         if i % 2000 == 0:
70             print("After %d steps, loss: %f" % (i, sess.run(loss, feed_dict={x: data, y_: label})))

具体报错如上,经过验证加入tf.reset_default_graph(),问题解决

InvalidArgumentError: You must feed a value for placeholder tensor ‘inputs/x_input’ with dtype float

[[Node: inputs/x_input = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
1
2
在使用TensorBoard进行可视化的时候,出现了上面描述的错误。这个错误和dtype没有关系。目前个人理解为是当前路径下不能存在一个以上的events文件。解决方案有以下几个: 
1. 到存储的路径下把之前生成的文件给删了; 
2. 引用自别人的评论:if you’re using IPython or Jupyter, it’ll cause that problem after running repeatedly.there are two main ways that you could fix that: 
A.
tf.reset_default_graph()
1
call firstly, before your tf operations codeB. 
using
with tf.Graph().as_default() as g:
# your tf operations code
1
2
For details, please refer https://stackoverflow.com/questions/35114376/error-when-computing-summaries-in-tensorflow如果有别的错误也可以参考这篇博文: 
http://blog.csdn.net/u012436149/article/details/53894364
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐