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

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")
主站蜘蛛池模板: 元朗区| 禹城市| 盐城市| 大城县| 舟曲县| 陆丰市| 丰台区| 新津县| 望谟县| 阜阳市| 黑水县| 沙雅县| 科技| 松滋市| 新干县| 平定县| 定陶县| 广安市| 清涧县| 阜南县| 长丰县| 廉江市| 墨脱县| 隆尧县| 长子县| 镇宁| 城市| 兴业县| 绥江县| 新晃| 禄劝| 交口县| 桦甸市| 来安县| 满洲里市| 肃宁县| 平阳县| 徐汇区| 南宫市| 阆中市| 上饶县|