求助 Cannot feed value of shape (10000,) for Tensor 'Placeholder:0', which has shape '(?,

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求助 Cannot feed value of shape (10000,) for Tensor 'Placeholder:0', which has shape '(?, 相关的知识,希望对你有一定的参考价值。

求助,使用python读取txt文件的一列一万个数据,n_input = 10000 x = tf.placeholder(tf.float32, [None, n_input]) sess.run(optimizer, feed_dict=x: batch_xs, y: batch_ys, keep_prob: dropout),报错ValueError: Cannot feed value of shape (10000,) for Tensor 'Placeholder:0', which has shape '(?, 10000)'请问怎么改呢?

参考技术A 把这个batch_xs添加一个维度,
batch_xs = np.expand_dims(batch_xs,0)

typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python sca

如上贴出了:错误信息和错误代码。

这个问题困扰了自己两天,报错大概是说输入的数据和接受的格式不一样,不能作为tensor。

后来问了大神,原因出在tf.reshape(),因为网络训练时用placeholder定义了输入格式,所以输入不能用tensor,而tf.reshape()返回结果就是一个tensor了,所以输入会报错。

因此改为了这种格式

灵机一动,全都使用numpy里面的方法提供格式的转换,这样就不会产生tensor形的变量了。改完以后成功运行

 

以上是关于求助 Cannot feed value of shape (10000,) for Tensor 'Placeholder:0', which has shape '(?, 的主要内容,如果未能解决你的问题,请参考以下文章

ValueError: Cannot feed value of shape (2,) for Tensor u'Placeholder_2:0', which has shape &

Cannot read property ‘value‘ of undefined

“JSON parse error: Cannot deserialize value of type `java.util.ArrayList<XXX>` from Object value ...

Cannot convert value of type ‘java.lang.String‘ to requi

解决vue-i18n Cannot translate the value of keypath 'XXX'. Use the value of keypath as default.

解决JSON parse error: Cannot deserialize instance of `java.lang.Integer` out of VALUE_TRUE token; nest