Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
dbad6f4c
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
286
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dbad6f4c
编写于
6月 22, 2020
作者:
C
chenguowei01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add resume model
上级
aa160894
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
5 deletion
+12
-5
dygraph/train.py
dygraph/train.py
+9
-3
dygraph/utils/utils.py
dygraph/utils/utils.py
+3
-2
未找到文件。
dygraph/train.py
浏览文件 @
dbad6f4c
...
...
@@ -79,7 +79,13 @@ def parse_args():
parser
.
add_argument
(
'--pretrained_model'
,
dest
=
'pretrained_model'
,
help
=
'The path of pretrained weight'
,
help
=
'The path of pretrained model'
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
'--resume_model'
,
dest
=
'resume_model'
,
help
=
'The path of resume model'
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
...
...
@@ -127,7 +133,7 @@ def train(model,
start_epoch
=
0
if
resume_model
is
not
None
:
start_epoch
=
resume
(
optimizer
,
resume_model
)
start_epoch
=
resume
(
model
,
optimizer
,
resume_model
)
elif
pretrained_model
is
not
None
:
load_pretrained_model
(
model
,
pretrained_model
)
...
...
@@ -233,7 +239,6 @@ def main(args):
# todo, may less one than len(loader)
num_steps_each_epoch
=
len
(
train_dataset
)
//
(
args
.
batch_size
*
ParallelEnv
().
nranks
)
print
(
num_steps_each_epoch
,
'num_steps_each_epoch'
)
decay_step
=
args
.
num_epochs
*
num_steps_each_epoch
lr_decay
=
fluid
.
layers
.
polynomial_decay
(
args
.
learning_rate
,
decay_step
,
end_learning_rate
=
0
,
power
=
0.9
)
...
...
@@ -253,6 +258,7 @@ def main(args):
num_epochs
=
args
.
num_epochs
,
batch_size
=
args
.
batch_size
,
pretrained_model
=
args
.
pretrained_model
,
resume_model
=
args
.
resume_model
,
save_interval_epochs
=
args
.
save_interval_epochs
,
num_classes
=
train_dataset
.
num_classes
,
num_workers
=
args
.
num_workers
)
...
...
dygraph/utils/utils.py
浏览文件 @
dbad6f4c
...
...
@@ -78,12 +78,13 @@ def load_pretrained_model(model, pretrained_model):
pretrained_model
))
def
resume
(
optimizer
,
resume_model
):
def
resume
(
model
,
optimizer
,
resume_model
):
if
resume_model
is
not
None
:
logging
.
info
(
'Resume model from {}'
.
format
(
resume_model
))
if
os
.
path
.
exists
(
resume_model
):
ckpt_path
=
os
.
path
.
join
(
resume_model
,
'model'
)
_
,
opti_state_dict
=
fluid
.
load_dygraph
(
ckpt_path
)
para_state_dict
,
opti_state_dict
=
fluid
.
load_dygraph
(
ckpt_path
)
model
.
set_dict
(
para_state_dict
)
optimizer
.
set_dict
(
opti_state_dict
)
epoch
=
resume_model
.
split
(
'_'
)[
-
1
]
if
epoch
.
isdigit
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录