keras中保存最优模型ModelCheckpoint

语法


keras.callbacks.ModelCheckpoint(filepath,monitor='val_loss',verbose=0,save_best_only=False, save_weights_only=False, mode='auto', period=1) 

参数说明:

filename:字符串,保存模型的路径
monitor:需要监视的值
verbose:信息展示模式,0或1(checkpoint的保存信息,类似Epoch 00001: saving model to ...)
save_best_only:当设置为True时,监测值有改进时才会保存当前的模型( the latest best model according to the quantity monitored will not be overwritten)
mode:‘auto’,‘min’,‘max’之一,在save_best_only=True时决定性能最佳模型的评判准则,例如,当监测值为val_acc时,模式应为max,当监测值为val_loss时,模式应为min。在auto模式下,评价准则由被监测值的名字自动推断。
save_weights_only:若设置为True,则只保存模型权重,否则将保存整个模型(包括模型结构,配置信息等)
period:CheckPoint之间的间隔的epoch数

注:如果用的是save_weights_only=True,在用load_weights导入参数前,需要先跑一遍模型,不然会报错。

参考
https://machinelearningmastery.com/check-point-deep-learning-models-keras/

https://keras.io/callbacks/

http://keras-cn.readthedocs.io/en/latest/other/callbacks/

--------------------- 
作者:刘伟ECJTU 
来源:CSDN 
原文:https://blog.csdn.net/breeze5428/article/details/80875323 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/qq_34840129/article/details/89047213