- 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")
推薦閱讀
- 輕松學(xué)C語言
- 輕松學(xué)C#
- Learning Apache Cassandra(Second Edition)
- MCSA Windows Server 2016 Certification Guide:Exam 70-741
- STM32G4入門與電機(jī)控制實(shí)戰(zhàn):基于X-CUBE-MCSDK的無刷直流電機(jī)與永磁同步電機(jī)控制實(shí)現(xiàn)
- 21天學(xué)通Java
- AWS Administration Cookbook
- Azure PowerShell Quick Start Guide
- 基于神經(jīng)網(wǎng)絡(luò)的監(jiān)督和半監(jiān)督學(xué)習(xí)方法與遙感圖像智能解譯
- Citrix? XenDesktop? 7 Cookbook
- Hands-On Data Warehousing with Azure Data Factory
- 人工智能:語言智能處理
- Visual Studio 2010 (C#) Windows數(shù)據(jù)庫項(xiàng)目開發(fā)
- ZigBee無線通信技術(shù)應(yīng)用開發(fā)
- 筆記本電腦電路分析與故障診斷