官术网_书友最值得收藏!

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")
主站蜘蛛池模板: 区。| 中卫市| 常熟市| 荥阳市| 方正县| 密山市| 吴旗县| 松桃| 鹤山市| 南阳市| 新绛县| 台山市| 保亭| 双流县| 侯马市| 信宜市| 北川| 九江市| 祁连县| 瑞昌市| 即墨市| 文化| 大理市| 前郭尔| 和林格尔县| 桃园市| 青阳县| 镇赉县| 上饶市| 蛟河市| 建始县| 郑州市| 全椒县| 响水县| 苏尼特右旗| 武夷山市| 莱阳市| 慈利县| 社旗县| 利辛县| 集安市|