Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PALM
提交
4c4807ad
P
PALM
项目概览
PaddlePaddle
/
PALM
通知
4
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PALM
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4c4807ad
编写于
11月 24, 2019
作者:
X
xixiaoyao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add save infermodel with train steps
上级
eef09152
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
7 deletion
+12
-7
paddlepalm/mtl_controller.py
paddlepalm/mtl_controller.py
+1
-2
paddlepalm/task_instance.py
paddlepalm/task_instance.py
+11
-5
未找到文件。
paddlepalm/mtl_controller.py
浏览文件 @
4c4807ad
...
...
@@ -348,7 +348,6 @@ class Controller(object):
task_attrs
=
[]
pred_task_attrs
=
[]
for
inst
in
instances
:
train_reader
=
inst
.
Reader
(
inst
.
config
,
phase
=
'train'
)
inst
.
reader
[
'train'
]
=
train_reader
train_parad
=
inst
.
Paradigm
(
inst
.
config
,
phase
=
'train'
,
backbone_config
=
bb_conf
)
...
...
@@ -593,7 +592,7 @@ class Controller(object):
cur_task
.
cur_train_step
+=
1
if
cur_task
.
save_infermodel_every_n_steps
>
0
and
cur_task
.
cur_train_step
%
cur_task
.
save_infermodel_every_n_steps
==
0
:
cur_task
.
save
(
suffix
=
'
-
step'
+
str
(
cur_task
.
cur_train_step
))
cur_task
.
save
(
suffix
=
'
.
step'
+
str
(
cur_task
.
cur_train_step
))
if
global_step
%
main_conf
.
get
(
'print_every_n_steps'
,
5
)
==
0
:
loss
=
rt_outputs
[
cur_task
.
name
+
'/loss'
]
...
...
paddlepalm/task_instance.py
浏览文件 @
4c4807ad
...
...
@@ -18,6 +18,8 @@ from paddlepalm.interface import task_paradigm as base_paradigm
import
os
import
json
from
paddle
import
fluid
import
importlib
from
paddlepalm.default_settings
import
*
def
check_req_args
(
conf
,
name
):
...
...
@@ -33,7 +35,7 @@ class TaskInstance(object):
self
.
_config
=
config
self
.
_verbose
=
verbose
check_req_args
(
config
)
check_req_args
(
config
,
name
)
# parse Reader and Paradigm
reader_name
=
config
[
'reader'
]
...
...
@@ -49,6 +51,7 @@ class TaskInstance(object):
self
.
_save_infermodel_path
=
os
.
path
.
join
(
self
.
_config
[
'save_path'
],
self
.
_name
,
'infer_model'
)
self
.
_save_ckpt_path
=
os
.
path
.
join
(
self
.
_config
[
'save_path'
],
'ckpt'
)
self
.
_save_infermodel_every_n_steps
=
config
.
get
(
'save_infermodel_every_n_steps'
,
-
1
)
# following flags can be fetch from instance config file
self
.
_is_target
=
config
.
get
(
'is_target'
,
True
)
...
...
@@ -77,9 +80,6 @@ class TaskInstance(object):
self
.
_pred_fetch_name_list
=
[]
self
.
_pred_fetch_var_list
=
[]
self
.
_Reader
=
None
self
.
_Paradigm
=
None
self
.
_exe
=
fluid
.
Executor
(
fluid
.
CPUPlace
())
self
.
_save_protocol
=
{
...
...
@@ -108,7 +108,9 @@ class TaskInstance(object):
dirpath
=
self
.
_save_infermodel_path
+
suffix
self
.
_pred_input_varname_list
=
[
str
(
i
)
for
i
in
self
.
_pred_input_varname_list
]
fluid
.
io
.
save_inference_model
(
dirpath
,
self
.
_pred_input_varname_list
,
self
.
_pred_fetch_var_list
,
self
.
_exe
,
export_for_deployment
=
True
)
# fluid.io.save_inference_model(dirpath, self._pred_input_varname_list, self._pred_fetch_var_list, self._exe, export_for_deployment = True)
prog
=
fluid
.
default_main_program
().
clone
()
fluid
.
io
.
save_inference_model
(
dirpath
,
self
.
_pred_input_varname_list
,
self
.
_pred_fetch_var_list
,
self
.
_exe
,
prog
)
conf
=
{}
for
k
,
strv
in
self
.
_save_protocol
.
items
():
...
...
@@ -222,6 +224,10 @@ class TaskInstance(object):
if
self
.
_verbose
:
print
(
'{}: mix_ratio is set to {}'
.
format
(
self
.
_name
,
self
.
_mix_ratio
))
@
property
def
save_infermodel_every_n_steps
(
self
):
return
self
.
_save_infermodel_every_n_steps
@
property
def
expected_train_steps
(
self
):
return
self
.
_expected_train_steps
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录