Mnist- 手写体数字识别
手写体数字集
from keras.datasets import mnist (x_train,y_train),(x_test,y_text) = mnist.load_data() import matplotlib.pyplot as plt plt.imshow(x_train[0]) plt.show()
x_train.shape
(60000,28,28)
y_train[0]
//显示前25个图像
import matplotlib.pyplot as plt fig, ax = plt.subplots(5,5, sharex='all', sharey='all') ax = ax.flatten() #将ax由n*m的Axes组展平成1*nm的Axes组 for i in range(25): img = train_images[i] ax[i].imshow(img) ax[i].set_title(train_labels[i]) ax[i].set_xticks([]) ax[i].set_yticks([]) plt.tight_layout() plt.show()
使用CNN对数据进行预测