typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...

时间:2022-06-04 01:41:50

typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...

typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...

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

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

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

因此改为了这种格式

typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...

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