Warning: Can save best model only with val_acc available, skipping

简介: 本文解决了在使用DenseNet网络结构保存最优模型时出现的"Warning: Can save best model only with val_acc available, skipping"问题,方法是将`ModelCheckpoint`回调函数中的`monitor`参数值从`val_acc`改为`val_accuracy`。

Warning: Can save best model only with val_acc available, skipping

今天使用DenseNet网络结构,在保存最优模型的时候出现Warning: Can save best model only with val_acc available, skipping

#回调函数2:保存最优模型
checkpoint = ModelCheckpoint(
                                filepath='./save_weights/myDenseNet121.h5', #保存模型的路径
                                monitor='val_acc', #需要监视的值
                                save_weights_only=False, #若设置为True,则只保存模型权重,否则将保存整个模型(包括模型结构,配置信息等)
                                save_best_only=True, #当设置为True时,监测值有改进时才会保存当前的模型
                                mode='auto', #当监测值为val_acc时,模式应为max,当监测值为val_loss时,模式应为min,在auto模式下,评价准则由被监测值的名字自动推断
                                period=1 #CheckPoint之间的间隔的epoch数
                            )

修改如下:

#回调函数2:保存最优模型
checkpoint = ModelCheckpoint(
                                filepath='./save_weights/myDenseNet121.h5', #保存模型的路径
             修改的地方:        monitor='val_accuracy', #需要监视的值
                                save_weights_only=False, #若设置为True,则只保存模型权重,否则将保存整个模型(包括模型结构,配置信息等)
                                save_best_only=True, #当设置为True时,监测值有改进时才会保存当前的模型
                                mode='auto', #当监测值为val_acc时,模式应为max,当监测值为val_loss时,模式应为min,在auto模式下,评价准则由被监测值的名字自动推断
                                period=1 #CheckPoint之间的间隔的epoch数
                            )
相关文章
|
7月前
|
TensorFlow 算法框架/工具 Python
【Tensorflow】Found unexpected keys that do not correspond to any Model output: dict_keys([‘model_outp
文章讨论了在使用Tensorflow 2.3时遇到的错误信息:"Found unexpected keys that do not correspond to any Model output: dict_keys(['model_output']). Expected: ['dense']"。这个问题通常发生在模型的输出层命名与model.fit_generator的生成器函数中返回的值的键不匹配时。
74 1
加载模型出现-RuntimeError: Error(s) in loading state_dict for Net:unexpected key(s) in state_dict: XXX
加载模型出现-RuntimeError: Error(s) in loading state_dict for Net:unexpected key(s) in state_dict: XXX
621 0
|
10月前
|
机器学习/深度学习 人工智能
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
605 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
|
JSON 移动开发 算法框架/工具
成功解决raise ValueError(‘No model found in config file.‘) ValueError: No model found in config file.
成功解决raise ValueError(‘No model found in config file.‘) ValueError: No model found in config file.
torch.distributed.init_process_group(‘gloo’, init_method=‘file://tmp/somefile’, rank=0, world_size=1
torch.distributed.init_process_group(‘gloo’, init_method=‘file://tmp/somefile’, rank=0, world_size=1
620 0
torch.distributed.init_process_group(‘gloo’, init_method=‘file://tmp/somefile’, rank=0, world_size=1
成功解决absl.flags._exceptions.IllegalFlagValueError: flag --train_size=inf: Expect argument to be a str
成功解决absl.flags._exceptions.IllegalFlagValueError: flag --train_size=inf: Expect argument to be a str
成功解决model_selection\_search.py:584: DeprecationWarning: "fit_params" as a constructor argument was d
成功解决model_selection\_search.py:584: DeprecationWarning: "fit_params" as a constructor argument was d