h5py must be installed first:
pip3 install h5py
save model
# 假设 model 是训练完毕的模型
# 将模型保存到文件 my_model.h5
model.save('my_model.h5')
load model
# 要载入模型,需要导入此函数
from keras.models import load_model
# 从文件 my_model.h5 中载入模型
model = load_model('my_model.h5')
Generally speaking, we should train the model in the training environment, and then take the trained model (ie, a file) to the production environment to deploy.