我是靠谱客的博主 动人白开水,最近开发中收集的这篇文章主要介绍KeyError: ‘Failed to format this callback filepath: “./saved_models/model_batch{batch}.h5“. Reason:,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
Environment: Win10 + tensorflow2.3.1 + python3.6
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 1330, in _get_file_path
file_path = self.filepath.format(epoch=epoch + 1, **logs)
KeyError: 'batch'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/WData/Development/table_direction_detection/4_directions/Derection-Classify/train.py", line 168, in <module>
trainer.train()
File "D:/WData/Development/table_direction_detection/4_directions/Derection-Classify/train.py", line 131, in train
callbacks=callbacks)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerasenginetraining.py", line 108, in _method_wrapper
return method(self, *args, **kwargs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerasenginetraining.py", line 1103, in fit
callbacks.on_train_batch_end(end_step, logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 440, in on_train_batch_end
self._call_batch_hook(ModeKeys.TRAIN, 'end', batch, logs=logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 289, in _call_batch_hook
self._call_batch_end_hook(mode, batch, logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 309, in _call_batch_end_hook
self._call_batch_hook_helper(hook_name, batch, logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 342, in _call_batch_hook_helper
hook(batch, logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 1240, in on_train_batch_end
self._save_model(epoch=self._current_epoch, logs=logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 1282, in _save_model
filepath = self._get_file_path(epoch, logs)
File "C:Users12575AppDataRoamingPythonPython36site-packagestensorflowpythonkerascallbacks.py", line 1333, in _get_file_path
'Reason: {}'.format(self.filepath, e))
KeyError: 'Failed to format this callback filepath: "./saved_models/model_batch{batch}.h5". Reason: 'batch''
Problem location:
修改配置文件config.yml中的
h5_savePath: './saved_models/model_batch{batch}.h5'
改成
h5_savePath: './saved_models/model_epoch{epoch}.h5'
最后
以上就是动人白开水为你收集整理的KeyError: ‘Failed to format this callback filepath: “./saved_models/model_batch{batch}.h5“. Reason:的全部内容,希望文章能够帮你解决KeyError: ‘Failed to format this callback filepath: “./saved_models/model_batch{batch}.h5“. Reason:所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复