- Deep Learning Quick Reference
- Mike Bernico
- 139字
- 2021-06-24 18:40:11
Saving and loading a trained Keras model
It's unlikely that you'll train a deep neural network and then apply it in the same script. Most likely, you will want to train your network and then save the structure and weights so that they can be used in a production-facing application designed to score new data. To do so, you'll need to be able to save and load your models.
Saving a model in Keras is very straightforward. You can use the model instance's .save() method to save the network structure and weights to an hdf5 file, as shown in the following code:
model.save("regression_model.h5")
That's really all there is to it. Loading a model from disk is just as simple. The code for doing this is given here for your reference:
from keras.models import load_model
model = load_model("regression_model.h5")
推薦閱讀
- 控制與決策系統仿真
- Visual C# 2008開發技術詳解
- 大數據挑戰與NoSQL數據庫技術
- 完全掌握AutoCAD 2008中文版:綜合篇
- Blender Compositing and Post Processing
- 電腦主板現場維修實錄
- Learning Azure Cosmos DB
- 突破,Objective-C開發速學手冊
- 單片機C語言程序設計完全自學手冊
- 悟透AutoCAD 2009案例自學手冊
- 電腦日常使用與維護322問
- Mastering GitLab 12
- Machine Learning Algorithms(Second Edition)
- 電氣控制與PLC原理及應用(歐姆龍機型)
- 30天學通Java Web項目案例開發