錯誤提示:
ValueError:The passed save_path is not a valid checkpoint: ./experiment_VGG/model-500000
三種可能的錯誤解決:
1、注意 "/" 和 "\" 符號不要弄錯
2、路徑最後不要加 "/"
4、從源碼來看,
if not checkpoint_management.checkpoint_exists(compat.as_text(save_path)):
raise ValueError("The passed save_path is not a valid checkpoint: "
+ compat.as_text(save_path))
是checkpoint_management.checkpoint_exists方法返回了False,表明路徑不存在或者路徑錯誤;比如
說我遇到就是這種情況,我是 ./experiment_VGG 文件夾存在,而 model-500000 文件夾不存在,於是將
路徑改爲 " ./experiment_VGG " 或者在" ./experiment_VGG "文件夾下新建 model-500000 文件夾亦
或者model-500000是一個.ckpt文件(即model-500000.ckpt,將該.cpkt文件放在experiment_VGG文件夾
下)即可解決錯誤了。
多說幾句源碼:
compat.as_text方法下面執行的代碼是:
if isinstance(bytes_or_text, _six.text_type):
return bytes_or_text
elif isinstance(bytes_or_text, bytes):
return bytes_or_text.decode(encoding)
else:
raise TypeError('Expected binary or unicode string, got %r' % bytes_or_text)
沒有彈出'Expected binary or unicode string, got %r' 這句話,說明不是在compat.as_text方法中出現的錯誤
於是再查看checkpoint_management.checkpoint_exists方法的代碼:
pathname = _prefix_to_checkpoint_path(checkpoint_prefix,
saver_pb2.SaverDef.V2)
if file_io.get_matching_files(pathname):
return True
elif file_io.get_matching_files(checkpoint_prefix):
return True
else:
return False
發現是最後一行返回的False,說明是路徑沒有匹配成功,更加確定了是路徑路徑不存在或者路徑錯誤