Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f28f41db
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f28f41db
编写于
6月 05, 2018
作者:
T
tangwei12
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update io.py annotations and codes
上级
6db240d7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
13 addition
and
14 deletion
+13
-14
python/paddle/fluid/io.py
python/paddle/fluid/io.py
+13
-14
未找到文件。
python/paddle/fluid/io.py
浏览文件 @
f28f41db
...
@@ -483,11 +483,11 @@ def save_checkpoint(executor,
...
@@ -483,11 +483,11 @@ def save_checkpoint(executor,
:param main_program
:param main_program
:param max_num_checkpoints
:param max_num_checkpoints
"""
"""
if
checkpoint_dir
is
None
:
if
checkpoint_dir
.
strip
()
is
None
:
raise
ValueError
(
"
The values of
'checkpoint_dir' should not be None"
)
raise
ValueError
(
"'checkpoint_dir' should not be None"
)
if
trainer_args
and
not
isinstance
(
trainer_args
,
dict
)
:
if
trainer_args
:
raise
TypeError
(
"The type of 'trainer_args' should be dict"
)
assert
isinstance
(
trainer_args
,
dict
)
if
not
os
.
path
.
isdir
(
checkpoint_dir
):
if
not
os
.
path
.
isdir
(
checkpoint_dir
):
os
.
makedirs
(
checkpoint_dir
)
os
.
makedirs
(
checkpoint_dir
)
...
@@ -514,11 +514,11 @@ def load_checkpoint(executor, checkpoint_dir, serial, main_program):
...
@@ -514,11 +514,11 @@ def load_checkpoint(executor, checkpoint_dir, serial, main_program):
:param main_program
:param main_program
"""
"""
if
checkpoint_dir
is
None
:
if
checkpoint_dir
.
strip
()
is
None
:
raise
ValueError
(
"
The values of
'checkpoint_dir' should not be None"
)
raise
ValueError
(
"'checkpoint_dir' should not be None"
)
if
serial
is
None
or
serial
<
0
:
if
serial
is
None
or
serial
<
0
:
raise
ValueError
(
"
The values of
'serial' should not be None or <0 "
)
raise
ValueError
(
"'serial' should not be None or <0 "
)
if
main_program
is
None
:
if
main_program
is
None
:
raise
ValueError
(
'main_program should not be None.'
)
raise
ValueError
(
'main_program should not be None.'
)
...
@@ -536,8 +536,8 @@ def clean_checkpoint(checkpoint_dir, delete_dir=False):
...
@@ -536,8 +536,8 @@ def clean_checkpoint(checkpoint_dir, delete_dir=False):
:param delete_dir
:param delete_dir
"""
"""
if
checkpoint_dir
is
None
:
if
checkpoint_dir
.
strip
()
is
None
:
raise
ValueError
(
"
The values of
'checkpoint_dir' should not be None"
)
raise
ValueError
(
"'checkpoint_dir' should not be None"
)
_lru_delete
(
checkpoint_dir
,
max_num_checkpoints
=
0
)
_lru_delete
(
checkpoint_dir
,
max_num_checkpoints
=
0
)
if
delete_dir
and
not
os
.
listdir
(
checkpoint_dir
):
if
delete_dir
and
not
os
.
listdir
(
checkpoint_dir
):
...
@@ -590,8 +590,8 @@ def save_persist_vars_without_grad(executor, dirname, program):
...
@@ -590,8 +590,8 @@ def save_persist_vars_without_grad(executor, dirname, program):
def
save_trainer_args
(
dirname
,
trainer_id
,
trainer_args
):
def
save_trainer_args
(
dirname
,
trainer_id
,
trainer_args
):
if
not
isinstance
(
trainer_args
,
dict
):
assert
isinstance
(
trainer_args
,
dict
)
raise
TypeError
(
"The type of 'trainer_args' should be dict"
)
cur_dir
=
_get_trainer_dir
(
dirname
,
trainer_id
)
cur_dir
=
_get_trainer_dir
(
dirname
,
trainer_id
)
for
name
,
value
in
trainer_args
.
iteritems
():
for
name
,
value
in
trainer_args
.
iteritems
():
...
@@ -602,12 +602,11 @@ def save_trainer_args(dirname, trainer_id, trainer_args):
...
@@ -602,12 +602,11 @@ def save_trainer_args(dirname, trainer_id, trainer_args):
def
load_trainer_args
(
checkpoint_dir
,
serial
,
trainer_id
,
trainer_args
):
def
load_trainer_args
(
checkpoint_dir
,
serial
,
trainer_id
,
trainer_args
):
assert
isinstance
(
trainer_args
,
list
)
cur_dir
=
_get_serial_dir
(
checkpoint_dir
,
serial
)
cur_dir
=
_get_serial_dir
(
checkpoint_dir
,
serial
)
cur_dir
=
_get_trainer_dir
(
cur_dir
,
trainer_id
)
cur_dir
=
_get_trainer_dir
(
cur_dir
,
trainer_id
)
if
not
isinstance
(
trainer_args
,
list
):
raise
TypeError
(
"The type of 'trainer_args' should be list"
)
ret_values
=
[]
ret_values
=
[]
for
arg
in
trainer_args
:
for
arg
in
trainer_args
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录