from sklearn.preprocessing import Label Encoder # 导入标签编码工具 from keras.utils.np_utils import to_categorical # 导入One-hot编码工具 label_encoder = Label Encoder() y = label_encoder.fit_transform(y_label) # 标签编码 y = to_categorical(y, 10) # 将标签转换为One-hot编码 X = np.array(X) # 将X从列表转换为张量数组 X = X/255 # 将X张量归一化