提交 3d103821 编写于 作者: K Kaipeng Deng 提交者: GitHub

raise error when checkpoint not exist (#2719)

上级 7c7fc504
......@@ -52,7 +52,8 @@ def load_pretrain(exe, prog, path):
path = get_weights_path(path)
if not os.path.exists(path):
logger.info('Model path {} does not exists.'.format(path))
raise ValueError("Model pretrain path {} does not "
"exists.".format(path))
logger.info('Loading pretrained model from {}...'.format(path))
......@@ -77,7 +78,8 @@ def load_checkpoint(exe, prog, path):
path = get_weights_path(path)
if not os.path.exists(path):
logger.info('Model path {} does not exists.'.format(path))
raise ValueError("Model checkpoint path {} does not "
"exists.".format(path))
logger.info('Loading checkpoint from {}...'.format(path))
fluid.io.load_persistables(exe, path, prog)
......@@ -127,6 +129,9 @@ def load_and_fusebn(exe, prog, path):
if is_url(path):
path = get_weights_path(path)
if not os.path.exists(path):
raise ValueError("Model path {} does not exists.".format(path))
def _if_exist(var):
b = os.path.exists(os.path.join(path, var.name))
if b:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册