Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
8af1c07f
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8af1c07f
编写于
7月 23, 2020
作者:
W
wangguanzhong
提交者:
GitHub
7月 23, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix save load in dygraph (#1092)
上级
13759f95
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
20 deletion
+11
-20
tools/eval.py
tools/eval.py
+2
-3
tools/train.py
tools/train.py
+9
-17
未找到文件。
tools/eval.py
浏览文件 @
8af1c07f
...
...
@@ -41,9 +41,8 @@ def run(FLAGS, cfg):
model
=
create
(
cfg
.
architecture
,
mode
=
'infer'
,
open_debug
=
cfg
.
open_debug
)
# Init Model
if
os
.
path
.
isfile
(
cfg
.
weights
):
param_state_dict
,
opti_state_dict
=
fluid
.
load_dygraph
(
cfg
.
weights
)
model
.
set_dict
(
param_state_dict
)
param_state_dict
=
fluid
.
dygraph
.
load_dygraph
(
cfg
.
weights
)[
0
]
model
.
set_dict
(
param_state_dict
)
# Data Reader
if
FLAGS
.
use_gpu
:
...
...
tools/train.py
浏览文件 @
8af1c07f
...
...
@@ -89,26 +89,13 @@ def run(FLAGS, cfg):
np
.
random
.
seed
(
local_seed
)
if
FLAGS
.
enable_ce
or
cfg
.
open_debug
:
fluid
.
default_startup_program
().
random_seed
=
1000
fluid
.
default_main_program
().
random_seed
=
1000
random
.
seed
(
0
)
np
.
random
.
seed
(
0
)
if
FLAGS
.
use_parallel
:
strategy
=
fluid
.
dygraph
.
parallel
.
prepare_context
()
parallel_log
=
"Note: use parallel "
# Model
main_arch
=
cfg
.
architecture
model
=
create
(
cfg
.
architecture
,
mode
=
'train'
,
open_debug
=
cfg
.
open_debug
)
# Parallel Model
if
FLAGS
.
use_parallel
:
#strategy = fluid.dygraph.parallel.prepare_context()
model
=
fluid
.
dygraph
.
parallel
.
DataParallel
(
model
,
strategy
)
parallel_log
+=
"with data parallel!"
print
(
parallel_log
)
# Optimizer
lr
=
create
(
'LearningRate'
)()
optimizer
=
create
(
'OptimizerBuilder'
)(
lr
,
model
.
parameters
())
...
...
@@ -122,11 +109,15 @@ def run(FLAGS, cfg):
FLAGS
.
ckpt_type
,
open_debug
=
cfg
.
open_debug
)
# Parallel Model
if
FLAGS
.
use_parallel
:
strategy
=
fluid
.
dygraph
.
parallel
.
prepare_context
()
model
=
fluid
.
dygraph
.
parallel
.
DataParallel
(
model
,
strategy
)
# Data Reader
start_iter
=
0
if
cfg
.
use_gpu
:
devices_num
=
fluid
.
core
.
get_cuda_device_count
(
)
if
FLAGS
.
use_parallel
else
1
devices_num
=
fluid
.
core
.
get_cuda_device_count
()
else
:
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
1
))
...
...
@@ -169,7 +160,9 @@ def run(FLAGS, cfg):
break
# Save Stage
if
iter_id
>
0
and
iter_id
%
int
(
cfg
.
snapshot_iter
)
==
0
:
if
iter_id
>
0
and
iter_id
%
int
(
cfg
.
snapshot_iter
)
==
0
and
fluid
.
dygraph
.
parallel
.
Env
(
).
local_rank
==
0
:
cfg_name
=
os
.
path
.
basename
(
FLAGS
.
config
).
split
(
'.'
)[
0
]
save_name
=
str
(
iter_id
)
if
iter_id
!=
cfg
.
max_iters
-
1
else
"model_final"
...
...
@@ -187,7 +180,6 @@ def main():
check_version
()
place
=
fluid
.
CUDAPlace
(
fluid
.
dygraph
.
parallel
.
Env
().
dev_id
)
\
if
FLAGS
.
use_parallel
else
fluid
.
CUDAPlace
(
0
)
\
if
cfg
.
use_gpu
else
fluid
.
CPUPlace
()
with
fluid
.
dygraph
.
guard
(
place
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录