1.bug背景
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor ‘input_1’ with dtype float and shape
[?,256,1,1]
在训练model的过程中,我使用Input(shape=(channel,H,W))输入了一个tensor后,想要将其转换为np.array格式以便我能使用一些numpy特有的函数,在查阅了网上的资料后决定采用eval函数实现我的梦想。但是实现过程却报了上面的bug,具体原因是什么呢?原因是我没有为placeholder tensor实例化,也就是说这个placeholder,他是个战力五的渣渣,想用它需要我们feed(投喂)它,具体怎么个投喂法,且听我慢慢道来。
2.解决之路
首先,我们需要大体上去了解一下我们的tensor都有些什么货色,为什么别人用eval函数能做到的我们却做不到。
tensor的种类:(constant、placeholder、Variable)
(1)constant:(常量)
通过constant方法创建,其是计算图(Computational Graph)中的起始节点,是传入数据。 创建过程
import tensorflow as tf
cons1 = tf