2016-04-30 71 views
1

训练我MNIST分类网后,我想对测试数据“预测”,并得到了有关测试输入的形状TensorFlow:形状误差

testimages = np.array(test) 
print(testimages.shape) 
> (28000, 784) 
feed_dict = {x: [testimages]} 
classification = sess.run(y, feed_dict) 

ValueError异常以下错误:无法养活形状的值(1 (尺寸(无),尺寸(784))

因此,形状是(28000,784)(它应该是(28000,784) be),但是当进入训练有素的网络时,它显示为(1,28,000,784)?

顺便说一句,训练我通过

trainlabels = np.array(train["label"]) 
trainimages = np.array(train.iloc[:, 1:]) 

包括训练数据,因为训练数据产生了第一列说明的标签。我使用熊猫进口。

回答

1

快速回答:从feed_dict = {x: [testimages]}变化feed_dict = {'x': testimages}

在自己的输入,通过feed_dict这是一本字典。不知道如果没关系。此外,您标签x的内部条目格式为[testimages]。所以如果testimages.shape = (28000, 784),用数组包围它会使它(1, 28000, 784)