在训练我的MNIST分类网络之后,我想对测试数据进行“预测”并得到关于测试输入形状的以下错误
testimages = np.array(test)
print(testimages.shape)
> (28000, 784)
feed_dict = {x: [testimages]}
classification = sess.run(y, feed_dict)
ValueError:无法为Tensor u'Placeholder_2:0'提供形状值(1,28000,784),其形状为(Dimension(None),Dimension(784))
那么形状怎么样(28000,784)(应该是这样)但是当进入受过训练的网络时,它会显示为(1,28000,784)?
顺便说一句,对于培训,我包括了培训数据
trainlabels = np.array(train["label"])
trainimages = np.array(train.iloc[:, 1:])
因为训练数据有第一栏说明标签 . 我正在使用Pandas进口 .
1 回答
快速回答:从
feed_dict = {x: [testimages]}
更改为feed_dict = {'x': testimages}
在您的输入中,您传递了
feed_dict
这是一本字典 . 不确定是否可以 . 此外,您标记为x
的内部条目的格式为[testimages]
. 因此,如果testimages.shape = (28000, 784)
,用数组包裹它会使它成为(1, 28000, 784)
.