Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
07ceca91
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看板
未验证
提交
07ceca91
编写于
8月 09, 2018
作者:
G
guochaorong
提交者:
GitHub
8月 09, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1125 from wanghaoshuang/ce_icnet
Add ce for icnet.
上级
adaa1ae2
5245d7e2
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
83 addition
and
9 deletion
+83
-9
fluid/icnet/.run_ce.sh
fluid/icnet/.run_ce.sh
+7
-0
fluid/icnet/_ce.py
fluid/icnet/_ce.py
+57
-0
fluid/icnet/eval.py
fluid/icnet/eval.py
+4
-3
fluid/icnet/icnet.py
fluid/icnet/icnet.py
+2
-2
fluid/icnet/train.py
fluid/icnet/train.py
+13
-4
未找到文件。
fluid/icnet/.run_ce.sh
0 → 100755
浏览文件 @
07ceca91
#!/bin/bash
# This file is only used for continuous evaluation.
rm
-rf
*
_factor.txt
python train.py
--use_gpu
=
True 1> log
cat
log | python _ce.py
fluid/icnet/_ce.py
0 → 100644
浏览文件 @
07ceca91
# this file is only used for continuous evaluation test!
import
os
import
sys
sys
.
path
.
append
(
os
.
environ
[
'ceroot'
])
from
kpi
import
CostKpi
,
DurationKpi
,
AccKpi
# NOTE kpi.py should shared in models in some way!!!!
train_cost_kpi
=
CostKpi
(
'train_cost'
,
0.02
,
actived
=
True
)
train_duration_kpi
=
DurationKpi
(
'train_duration'
,
0.06
,
actived
=
True
)
tracking_kpis
=
[
train_cost_kpi
,
train_duration_kpi
,
]
def
parse_log
(
log
):
'''
This method should be implemented by model developers.
The suggestion:
each line in the log should be key, value, for example:
"
train_cost
\t
1.0
test_cost
\t
1.0
train_cost
\t
1.0
train_cost
\t
1.0
train_acc
\t
1.2
"
'''
for
line
in
log
.
split
(
'
\n
'
):
fs
=
line
.
strip
().
split
(
'
\t
'
)
print
(
fs
)
if
len
(
fs
)
==
3
and
fs
[
0
]
==
'kpis'
:
kpi_name
=
fs
[
1
]
kpi_value
=
float
(
fs
[
2
])
yield
kpi_name
,
kpi_value
def
log_to_ce
(
log
):
kpi_tracker
=
{}
for
kpi
in
tracking_kpis
:
kpi_tracker
[
kpi
.
name
]
=
kpi
for
(
kpi_name
,
kpi_value
)
in
parse_log
(
log
):
print
(
kpi_name
,
kpi_value
)
kpi_tracker
[
kpi_name
].
add_record
(
kpi_value
)
kpi_tracker
[
kpi_name
].
persist
()
if
__name__
==
'__main__'
:
log
=
sys
.
stdin
.
read
()
log_to_ce
(
log
)
fluid/icnet/eval.py
浏览文件 @
07ceca91
...
...
@@ -20,12 +20,12 @@ add_arg('use_gpu', bool, True, "Whether use GPU to test.")
def
cal_mean_iou
(
wrong
,
correct
):
sum
=
wrong
+
c
erro
ct
sum
=
wrong
+
c
orre
ct
true_num
=
(
sum
!=
0
).
sum
()
for
i
in
len
(
sum
):
for
i
in
range
(
len
(
sum
)
):
if
sum
[
i
]
==
0
:
sum
[
i
]
=
1
return
(
c
erro
ct
.
astype
(
"float64"
)
/
sum
).
sum
()
/
true_num
return
(
c
orre
ct
.
astype
(
"float64"
)
/
sum
).
sum
()
/
true_num
def
create_iou
(
predict
,
label
,
mask
,
num_classes
,
image_shape
):
...
...
@@ -84,6 +84,7 @@ def eval(args):
sys
.
stdout
.
flush
()
iou
=
cal_mean_iou
(
out_wrong
,
out_right
)
print
"
\n
mean iou: %.3f"
%
iou
print
"kpis test_acc %f"
%
iou
def
main
():
...
...
fluid/icnet/icnet.py
浏览文件 @
07ceca91
...
...
@@ -184,7 +184,7 @@ def res_block(input, filter_num, padding=0, dilation=None, name=None):
tmp
=
conv
(
tmp
,
1
,
1
,
filter_num
,
1
,
1
,
name
=
name
+
"_1_1_increase"
)
tmp
=
bn
(
tmp
,
relu
=
False
)
tmp
=
input
+
tmp
tmp
=
fluid
.
layers
.
relu
(
tmp
,
name
=
name
+
"_relu"
)
tmp
=
fluid
.
layers
.
relu
(
tmp
)
return
tmp
...
...
@@ -227,7 +227,7 @@ def proj_block(input, filter_num, padding=0, dilation=None, stride=1,
tmp
=
conv
(
tmp
,
1
,
1
,
filter_num
,
1
,
1
,
name
=
name
+
"_1_1_increase"
)
tmp
=
bn
(
tmp
,
relu
=
False
)
tmp
=
proj_bn
+
tmp
tmp
=
fluid
.
layers
.
relu
(
tmp
,
name
=
name
+
"_relu"
)
tmp
=
fluid
.
layers
.
relu
(
tmp
)
return
tmp
...
...
fluid/icnet/train.py
浏览文件 @
07ceca91
...
...
@@ -11,6 +11,10 @@ from utils import add_arguments, print_arguments, get_feeder_data
from
paddle.fluid.layers.learning_rate_scheduler
import
_decay_step_counter
from
paddle.fluid.initializer
import
init_on_cpu
SEED
=
90
# random seed must set before configuring the network.
fluid
.
default_startup_program
().
random_seed
=
SEED
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
...
...
@@ -27,9 +31,9 @@ LAMBDA2 = 0.4
LAMBDA3
=
1.0
LEARNING_RATE
=
0.003
POWER
=
0.9
LOG_PERIOD
=
1
CHECKPOINT_PERIOD
=
100
0
TOTAL_STEP
=
600
00
LOG_PERIOD
=
1
00
CHECKPOINT_PERIOD
=
100
TOTAL_STEP
=
1
00
no_grad_set
=
[]
...
...
@@ -97,10 +101,13 @@ def train(args):
sub124_loss
=
0.
train_reader
=
cityscape
.
train
(
args
.
batch_size
,
flip
=
args
.
random_mirror
,
scaling
=
args
.
random_scaling
)
start_time
=
time
.
time
()
while
True
:
# train a pass
for
data
in
train_reader
():
if
iter_id
>
TOTAL_STEP
:
end_time
=
time
.
time
()
print
"kpis train_duration %f"
%
(
end_time
-
start_time
)
return
iter_id
+=
1
results
=
exe
.
run
(
...
...
@@ -115,13 +122,15 @@ def train(args):
print
"Iter[%d]; train loss: %.3f; sub4_loss: %.3f; sub24_loss: %.3f; sub124_loss: %.3f"
%
(
iter_id
,
t_loss
/
LOG_PERIOD
,
sub4_loss
/
LOG_PERIOD
,
sub24_loss
/
LOG_PERIOD
,
sub124_loss
/
LOG_PERIOD
)
print
"kpis train_cost %f"
%
(
t_loss
/
LOG_PERIOD
)
t_loss
=
0.
sub4_loss
=
0.
sub24_loss
=
0.
sub124_loss
=
0.
sys
.
stdout
.
flush
()
if
iter_id
%
CHECKPOINT_PERIOD
==
0
:
if
iter_id
%
CHECKPOINT_PERIOD
==
0
and
args
.
checkpoint_path
is
not
None
:
dir_name
=
args
.
checkpoint_path
+
"/"
+
str
(
iter_id
)
fluid
.
io
.
save_persistables
(
exe
,
dirname
=
dir_name
)
print
"Saved checkpoint: %s"
%
(
dir_name
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录