Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f35daf3e
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看板
提交
f35daf3e
编写于
8月 07, 2018
作者:
B
baiyfbupt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update ce
上级
2a1124c6
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
21 addition
and
31 deletion
+21
-31
fluid/object_detection/train.py
fluid/object_detection/train.py
+21
-31
未找到文件。
fluid/object_detection/train.py
浏览文件 @
f35daf3e
...
@@ -11,6 +11,11 @@ import reader
...
@@ -11,6 +11,11 @@ import reader
from
mobilenet_ssd
import
mobile_net
from
mobilenet_ssd
import
mobile_net
from
utility
import
add_arguments
,
print_arguments
from
utility
import
add_arguments
,
print_arguments
SEED
=
90
# random seed must set before configuring the network.
fluid
.
default_startup_program
().
random_seed
=
SEED
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
# yapf: disable
...
@@ -150,31 +155,9 @@ def train(args,
...
@@ -150,31 +155,9 @@ def train(args,
print
(
"Pass {0}, test map {1}"
.
format
(
pass_id
,
test_map
))
print
(
"Pass {0}, test map {1}"
.
format
(
pass_id
,
test_map
))
return
best_map
return
best_map
def
ce_map
(
pass_id
,
best_map
):
total_time
=
0.0
_
,
accum_map
=
map_eval
.
get_map_var
()
map_eval
.
reset
(
exe
)
every_train_map
=
[]
for
batch_id
,
data
in
enumerate
(
train_reader
()):
out
,
=
exe
.
run
(
test_program
,
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
accum_map
])
if
batch_id
%
20
==
0
:
every_train_map
.
append
(
out
)
train_map
=
np
.
mean
(
every_train_map
)
_
,
accum_map
=
map_eval
.
get_map_var
()
map_eval
.
reset
(
exe
)
every_test_map
=
[]
for
batch_id
,
data
in
enumerate
(
test_reader
()):
out
,
=
exe
.
run
(
test_program
,
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
accum_map
])
if
batch_id
%
20
==
0
:
every_test_map
.
append
(
out
)
test_map
=
np
.
mean
(
every_test_map
)
return
(
train_map
,
test_map
)
for
pass_id
in
range
(
num_passes
):
for
pass_id
in
range
(
num_passes
):
epoch_idx
=
pass_id
+
1
start_time
=
time
.
time
()
start_time
=
time
.
time
()
prev_start_time
=
start_time
prev_start_time
=
start_time
every_pass_loss
=
[]
every_pass_loss
=
[]
...
@@ -200,20 +183,27 @@ def train(args,
...
@@ -200,20 +183,27 @@ def train(args,
pass_id
,
batch_id
,
loss_v
,
start_time
-
prev_start_time
))
pass_id
,
batch_id
,
loss_v
,
start_time
-
prev_start_time
))
end_time
=
time
.
time
()
end_time
=
time
.
time
()
best_map
=
test
(
pass_id
,
best_map
)
if
args
.
for_model_ce
:
if
args
.
for_model_ce
:
gpu_num
=
get_cards
()
total_time
+=
end_time
-
start_time
train_avg_loss
=
np
.
mean
(
every_pass_loss
)
train_avg_loss
=
np
.
mean
(
every_pass_loss
)
train_avg_acc
,
test_avg_acc
=
ce_map
(
pass_id
,
best_map
)
if
gpu_num
==
1
:
print
(
"kpis train_acc %f"
%
train_avg_acc
)
print
(
"kpis train_cost %s"
%
train_avg_loss
)
print
(
"kpis train_cost %f"
%
train_avg_loss
)
print
(
"kpis train_speed %s"
%
(
total_time
/
epoch_idx
))
print
(
"kpis test_acc %f"
%
test_avg_acc
)
else
:
print
(
"kpis train_duration %f"
%
(
end_time
-
start_time
))
print
(
"kpis train_cost_card%s %s"
%
(
gpu_num
,
train_avg_loss
))
print
(
"kpis train_speed_card%s %f"
%
(
gpu_num
,
total_time
/
epoch_idx
))
best_map
=
test
(
pass_id
,
best_map
)
if
pass_id
%
10
==
0
or
pass_id
==
num_passes
-
1
:
if
pass_id
%
10
==
0
or
pass_id
==
num_passes
-
1
:
save_model
(
str
(
pass_id
))
save_model
(
str
(
pass_id
))
print
(
"Best test map {0}"
.
format
(
best_map
))
print
(
"Best test map {0}"
.
format
(
best_map
))
def
get_cards
():
cards
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
)
num
=
len
(
cards
.
split
(
","
))
return
num
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录