from keras.utils import to_categorical # 导入keras.utils工具库的类别转换工具 X_train = X_train_image.reshape(60000, 28, 28, 1) # 给标签增加一个维度 X_test = X_test_image.reshape(10000, 28, 28, 1) # 给标签增加一个维度 y_train = to_categorical(y_train_lable, 10) # 特征转换为one-hot编码 y_test = to_categorical(y_test_lable, 10) # 特征转换为one-hot编码 print ("训练集张量形状:", X_train.shape) # 训练集张量的形状 print ("第一个数据标签:", y_train[0]) # 显示标签集的第一个数据