##用LSTM实现MNIST手写数字识别
就像开始学习编程语言时入门程序是‘Hello World’一样,mnist就是机器学习中的‘Hello World’。
1、MNIST手写数字
本数据库有x_train为60,000个用于训练的28*28的灰度手写数字图片,x_test为10,000个测试图片,如下图所示。y_train,y_test是标记的数字,值为0-9。
(1)从keras数据库中加载数据集
from keras.datasets import mnist
#加载数据
(x_train, y_train), (x_test, y_test) = mnist.load_data()
print('x_train.shape:',x_train.shape)
print('x_test.shape:',x_test.shape)
输出:
('x_train.shape:', (60000, 28, 28))
('x_test.shape:'