You must feed a value for placeholder tensor 'Placeholder_2' with dtype float
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了You must feed a value for placeholder tensor 'Placeholder_2' with dtype float相关的知识,希望对你有一定的参考价值。
在使用dropout设置了一个占位符keepProb = tf.placeholder(tf.float32)
使用sess.run(train_step, feed_dict=
keepProb: 0.6,
x_data: rand_x[:, 0:11],
x_data1: rand_x[:, 11:22],
y_target: rand_y
)
报错InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder_2' with dtype float
[[node Placeholder_2 (defined at D:/study/test.py:45) = Placeholder[dtype=DT_FLOAT, shape=<unknown>, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
要怎么解决
Tensorflow报错:InvalidArgumentError: You must feed a value for placeholder tensor 'input_y' wi
此错误神奇之处是每次第一次运行不会报错,第二次、第三次第四次。。。。就都报错了。关掉重启,又不报错了,运行完再运行一次立马报错!搞笑!
折磨了我半天,终于被我给解决了!
问题解决来源于这边博客:https://blog.csdn.net/m0_37870649/article/details/79428960
我的解决方法:在fit模型的代码前面加入一行代码:tf.reset_default_graph()
如下图:
我原本是猜想自定义TextCNN模型的代码中出了问题,但其实这个错误和dtype没有关系。目前个人理解为是在自定义的TextCNN模型代码中有一段生成graph的代码。每第一次运行时不会出错了,同时生成了graph,再次、再再次都运行出错,原因或许是发生了冲突。那我重置一下就行了,于是便有了tf.reset_default_greph()成功解决问题的情况了。
自定义TextCNN代码部分内容:
For details, please refer https://stackoverflow.com/questions/35114376/error-when-computing-summaries-in-tensorflow
以上是关于You must feed a value for placeholder tensor 'Placeholder_2' with dtype float的主要内容,如果未能解决你的问题,请参考以下文章
You must feed a value for placeholder tensor 'Placeholder' with dtype float......?
You must feed a value for placeholder tensor 'Placeholder_2' with dtype float
Tensorflow报错:InvalidArgumentError: You must feed a value for placeholder tensor 'input_y' wi
求助 Cannot feed value of shape (10000,) for Tensor 'Placeholder:0', which has shape '(?,
python -- 解决If using all scalar values, you must pass an index问题
pandas.apply expand column ValueError: If using all scalar values, you must pass a index