Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
df12c591
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
df12c591
编写于
3月 29, 2019
作者:
T
typhoonzero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine
上级
807faec9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
5 addition
and
11 deletion
+5
-11
fluid/PaddleCV/image_classification/dist_train/dist_train.py
fluid/PaddleCV/image_classification/dist_train/dist_train.py
+3
-10
fluid/PaddleCV/image_classification/utils/fp16_utils.py
fluid/PaddleCV/image_classification/utils/fp16_utils.py
+2
-1
未找到文件。
fluid/PaddleCV/image_classification/dist_train/dist_train.py
浏览文件 @
df12c591
...
@@ -296,11 +296,6 @@ def train_parallel(args):
...
@@ -296,11 +296,6 @@ def train_parallel(args):
# scope=fluid.global_scope().new_scope()
# scope=fluid.global_scope().new_scope()
# )
# )
print
(
"Run test before head"
)
test_fetch_list
=
[
test_cost
.
name
,
test_acc1
.
name
,
test_acc5
.
name
]
test_ret
=
test_single
(
startup_exe
,
test_prog
,
args
,
test_pyreader
,
test_fetch_list
)
print
(
"End run test before head"
)
over_all_start
=
time
.
time
()
over_all_start
=
time
.
time
()
fetch_list
=
[
train_cost
.
name
,
train_acc1
.
name
,
train_acc5
.
name
]
fetch_list
=
[
train_cost
.
name
,
train_acc1
.
name
,
train_acc5
.
name
]
steps_per_pass
=
args
.
total_images
/
args
.
batch_size
/
args
.
dist_env
[
"num_trainers"
]
steps_per_pass
=
args
.
total_images
/
args
.
batch_size
/
args
.
dist_env
[
"num_trainers"
]
...
@@ -316,8 +311,8 @@ def train_parallel(args):
...
@@ -316,8 +311,8 @@ def train_parallel(args):
if
batch_id
%
30
==
0
:
if
batch_id
%
30
==
0
:
fetch_ret
=
exe
.
run
(
fetch_list
)
fetch_ret
=
exe
.
run
(
fetch_list
)
fetched_data
=
[
np
.
mean
(
np
.
array
(
d
))
for
d
in
fetch_ret
]
fetched_data
=
[
np
.
mean
(
np
.
array
(
d
))
for
d
in
fetch_ret
]
print
(
"Pass
%d, batch %d
, loss %s, acc1: %s, acc5: %s, avg batch time %.4f"
%
print
(
"Pass
[%d/%d], batch [%d/%d]
, loss %s, acc1: %s, acc5: %s, avg batch time %.4f"
%
(
pass_id
,
batch_id
,
fetched_data
[
0
],
fetched_data
[
1
],
(
pass_id
,
args
.
num_epochs
,
batch_id
,
steps_per_pass
,
fetched_data
[
0
],
fetched_data
[
1
],
fetched_data
[
2
],
(
time
.
time
()
-
start_time
)
/
batch_id
))
fetched_data
[
2
],
(
time
.
time
()
-
start_time
)
/
batch_id
))
else
:
else
:
fetch_ret
=
exe
.
run
([])
fetch_ret
=
exe
.
run
([])
...
@@ -333,8 +328,7 @@ def train_parallel(args):
...
@@ -333,8 +328,7 @@ def train_parallel(args):
print_train_time
(
start_time
,
time
.
time
(),
num_samples
)
print_train_time
(
start_time
,
time
.
time
(),
num_samples
)
train_pyreader
.
reset
()
train_pyreader
.
reset
()
if
pass_id
>=
args
.
start_test_pass
:
if
pass_id
>
args
.
start_test_pass
:
if
args
.
multi_batch_repeat
>
1
:
if
args
.
multi_batch_repeat
>
1
:
copyback_repeat_bn_params
(
train_prog
)
copyback_repeat_bn_params
(
train_prog
)
test_fetch_list
=
[
test_cost
.
name
,
test_acc1
.
name
,
test_acc5
.
name
]
test_fetch_list
=
[
test_cost
.
name
,
test_acc1
.
name
,
test_acc5
.
name
]
...
@@ -349,7 +343,6 @@ def train_parallel(args):
...
@@ -349,7 +343,6 @@ def train_parallel(args):
if
not
os
.
path
.
isdir
(
model_path
):
if
not
os
.
path
.
isdir
(
model_path
):
os
.
makedirs
(
model_path
)
os
.
makedirs
(
model_path
)
fluid
.
io
.
save_persistables
(
startup_exe
,
model_path
,
main_program
=
train_prog
)
fluid
.
io
.
save_persistables
(
startup_exe
,
model_path
,
main_program
=
train_prog
)
startup_exe
.
close
()
startup_exe
.
close
()
print
(
"total train time: "
,
time
.
time
()
-
over_all_start
)
print
(
"total train time: "
,
time
.
time
()
-
over_all_start
)
...
...
fluid/PaddleCV/image_classification/utils/fp16_utils.py
浏览文件 @
df12c591
...
@@ -54,7 +54,7 @@ def _update_role_var_grad(prog, params_grads):
...
@@ -54,7 +54,7 @@ def _update_role_var_grad(prog, params_grads):
role
=
op
.
attr
(
"op_role"
)
role
=
op
.
attr
(
"op_role"
)
if
role
&
int
(
BACKWARD
)
and
op
.
has_attr
(
"op_role_var"
):
if
role
&
int
(
BACKWARD
)
and
op
.
has_attr
(
"op_role_var"
):
# have backward bits then remove all op_role_var
# have backward bits then remove all op_role_var
op
.
desc
.
_
remove_attr
(
"op_role_var"
)
op
.
desc
.
remove_attr
(
"op_role_var"
)
for
op
in
prog
.
global_block
().
ops
:
for
op
in
prog
.
global_block
().
ops
:
if
op
.
type
==
"allreduce"
:
if
op
.
type
==
"allreduce"
:
allreduce_role_var
=
[]
allreduce_role_var
=
[]
...
@@ -95,6 +95,7 @@ def create_master_params_grads(params_grads, main_prog, startup_prog, scale_loss
...
@@ -95,6 +95,7 @@ def create_master_params_grads(params_grads, main_prog, startup_prog, scale_loss
else
:
else
:
reduced_master_grad
=
master_grad
reduced_master_grad
=
master_grad
params_grads_to_apply
.
append
([
master_param
,
reduced_master_grad
])
params_grads_to_apply
.
append
([
master_param
,
reduced_master_grad
])
# update program op role var acording to master grads before allreduce.
# update program op role var acording to master grads before allreduce.
_update_role_var_grad
(
main_prog
,
master_params_grads
)
_update_role_var_grad
(
main_prog
,
master_params_grads
)
main_prog
.
_current_role
=
tmp_role
main_prog
.
_current_role
=
tmp_role
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录