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

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")
主站蜘蛛池模板: 瑞金市| 策勒县| 合作市| 皮山县| 长沙市| 深水埗区| 东源县| 太仆寺旗| 花莲市| 邹城市| 石渠县| 西贡区| 无极县| 泰和县| 封丘县| 阳东县| 赫章县| 开阳县| 美姑县| 汨罗市| 金秀| 临桂县| 白玉县| 玉溪市| 剑阁县| 织金县| 万州区| 龙山县| 博罗县| 昭平县| 霸州市| 邢台县| 白朗县| 手机| 武威市| 龙陵县| 项城市| 铜鼓县| 永平县| 潜江市| 岳西县|