【发布时间】:2017-09-11 10:39:32
【问题描述】:
我是 Keras 的新手,我正在学习构建卷积神经网络模型。我正在使用 MNIST 数据集。
(X_train, y_train), (X_test, y_test) = mnist.load_data()
在构建和评估之后,我的准确率达到了 99% 以上。
model = NN_model() # Sequential model built with multiple Convolution and pooling layers
model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=3, batch_size=200, verbose=2)
scores = model.evaluate(X_test, y_test, verbose=0)
现在,我想手动检查结果,方法是选择随机图像,使用 matplotlib 打印,然后使用学习模型进行预测。例如,X_test[39] 数据看起来像 this。
print(model.predict(X_test[39],verbose=2))
当我尝试这样做时,它要求我将预处理数据转换为 conv2d 数据,因为模型正在转换它。如何手动将此转换应用于测试数据?
ValueError: Error when checking : expected conv2d_1_input to have 4 dimensions, but got array with shape (1, 28, 28)
【问题讨论】:
标签: python neural-network keras conv-neural-network