Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
PaddleRec
提交
4310c411
P
PaddleRec
项目概览
BaiXuePrincess
/
PaddleRec
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleRec
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleRec
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4310c411
编写于
7月 27, 2020
作者:
M
malin10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
b02bc6ca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
7 deletion
+26
-7
core/trainers/framework/runner.py
core/trainers/framework/runner.py
+26
-7
未找到文件。
core/trainers/framework/runner.py
浏览文件 @
4310c411
...
...
@@ -77,9 +77,10 @@ class RunnerBase(object):
name
=
"dataset."
+
reader_name
+
"."
if
envs
.
get_global_env
(
name
+
"type"
)
==
"DataLoader"
:
self
.
_executor_dataloader_train
(
model_dict
,
context
)
return
self
.
_executor_dataloader_train
(
model_dict
,
context
)
else
:
self
.
_executor_dataset_train
(
model_dict
,
context
)
return
None
def
_executor_dataset_train
(
self
,
model_dict
,
context
):
reader_name
=
model_dict
[
"dataset_name"
]
...
...
@@ -137,8 +138,10 @@ class RunnerBase(object):
metrics_varnames
=
[]
metrics_format
=
[]
metrics_names
=
[
"total_batch"
]
metrics_format
.
append
(
"{}: {{}}"
.
format
(
"batch"
))
for
name
,
var
in
metrics
.
items
():
metrics_names
.
append
(
name
)
metrics_varnames
.
append
(
var
.
name
)
metrics_format
.
append
(
"{}: {{}}"
.
format
(
name
))
metrics_format
=
", "
.
join
(
metrics_format
)
...
...
@@ -147,6 +150,7 @@ class RunnerBase(object):
reader
.
start
()
batch_id
=
0
scope
=
context
[
"model"
][
model_name
][
"scope"
]
result
=
None
with
fluid
.
scope_guard
(
scope
):
try
:
while
True
:
...
...
@@ -169,7 +173,8 @@ class RunnerBase(object):
reader
.
reset
()
if
batch_id
>
0
:
print
(
metrics_format
.
format
(
*
metrics
))
result
=
dict
(
zip
(
metrics_names
,
metrics
))
return
result
def
_get_dataloader_program
(
self
,
model_dict
,
context
):
model_name
=
model_dict
[
"name"
]
...
...
@@ -340,10 +345,16 @@ class SingleRunner(RunnerBase):
for
epoch
in
range
(
epochs
):
for
model_dict
in
context
[
"phases"
]:
begin_time
=
time
.
time
()
self
.
_run
(
context
,
model_dict
)
result
=
self
.
_run
(
context
,
model_dict
)
end_time
=
time
.
time
()
seconds
=
end_time
-
begin_time
print
(
"epoch {} done, use time: {}"
.
format
(
epoch
,
seconds
))
message
=
"epoch {} done, use time: {}"
.
format
(
epoch
,
seconds
)
if
not
result
is
None
:
for
key
in
result
:
if
key
.
upper
().
startswith
(
"BATCH_"
):
continue
message
+=
", {}: {}"
.
format
(
key
,
result
[
key
])
print
(
message
)
with
fluid
.
scope_guard
(
context
[
"model"
][
model_dict
[
"name"
]][
"scope"
]):
train_prog
=
context
[
"model"
][
model_dict
[
"name"
]][
...
...
@@ -477,16 +488,24 @@ class SingleInferRunner(RunnerBase):
def
run
(
self
,
context
):
self
.
_dir_check
(
context
)
self
.
epoch_model_name_list
.
sort
()
for
index
,
epoch_name
in
enumerate
(
self
.
epoch_model_name_list
):
for
model_dict
in
context
[
"phases"
]:
self
.
_load
(
context
,
model_dict
,
self
.
epoch_model_path_list
[
index
])
begin_time
=
time
.
time
()
self
.
_run
(
context
,
model_dict
)
result
=
self
.
_run
(
context
,
model_dict
)
end_time
=
time
.
time
()
seconds
=
end_time
-
begin_time
print
(
"Infer {} of {} done, use time: {}"
.
format
(
model_dict
[
"name"
],
epoch_name
,
seconds
))
message
=
"Infer {} of epoch {} done, use time: {}"
.
format
(
model_dict
[
"name"
],
epoch_name
,
seconds
)
if
not
result
is
None
:
for
key
in
result
:
if
key
.
upper
().
startswith
(
"BATCH_"
):
continue
message
+=
", {}: {}"
.
format
(
key
,
result
[
key
])
print
(
message
)
context
[
"status"
]
=
"terminal_pass"
def
_load
(
self
,
context
,
model_dict
,
model_path
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录