版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_31119155/article/details/90080078
语法
Keras.callbacks.ModelCheckpoint(filepath,monitor,verbose,save_best_only,mode,save_weights_only,period )
参数说明
filepath:模型保存的路径
monitor:需要监视的值
verbose:信息展示的模式 (取值 0,1,2)
0:不在标准输出流输出日志信息
1:输出进度条记录
2:为每个epoch输出一行记录
save_best_only (bool)
True:检测值有改进时才会保存当前的模型
False:每epoch都保存
mode (取值 max,min,auo)
当 save_best_only=true 时,依据什么样的模式重写模型
if monitor='val_acc' mode=max
if monitor='val_loss' mode=min
if mode=auto 他会自动推导
save_weights_only (bool)
if save_weights_only=True, mode.save_weights(filepath)
if save_weights_only=False,mode.save(filepath)
period (int)
checkpoints之间的epoch
例子
model_checkpoint = ModelCheckpoint(filepath='unet_membrane.hdf5',
monitor='loss',
verbose=2,
save_best_only=True,
save_weights_only=False,
mode='auto',
period=1)