1.模型保存
model.save_model()
可以保存网络结构权重以及优化器的参数
model.save_weights()
仅仅保存权重
2.模型加载
from keras.models import load_model
load_model()
只能load 由save_model保存的,将模型和weight全load进来
filepath: String, path to the saved model.
custom_objects: Optional dictionary mapping names
(strings) to custom classes or functions to be
considered during deserialization.
compile: Boolean, whether to compile the model
after loading.
model.load_weights(self, filepath, by_name=False):
在加载权重之前,model必须编译好
metrics = ['accuracy']
if self.nb_classes >= 10:
metrics.append('top_k_categorical_accuracy')
# self.input_shape = (seq_length, features_length)
self.model,self.original_model = self.zf_model()
optimizer