Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
d3bad33f
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d3bad33f
编写于
6月 30, 2020
作者:
S
shippingwang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add print_interval and refine override
上级
9d3f36b7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
14 deletion
+33
-14
ppcls/utils/config.py
ppcls/utils/config.py
+6
-1
tools/eval.py
tools/eval.py
+1
-1
tools/program.py
tools/program.py
+19
-6
tools/run.sh
tools/run.sh
+2
-1
tools/train.py
tools/train.py
+5
-5
未找到文件。
ppcls/utils/config.py
浏览文件 @
d3bad33f
...
...
@@ -144,9 +144,14 @@ def override(dl, ks, v):
override
(
dl
[
k
],
ks
[
1
:],
v
)
else
:
if
len
(
ks
)
==
1
:
assert
ks
[
0
]
in
dl
,
(
'{} is not exist in {}'
.
format
(
ks
[
0
],
dl
))
#assert ks[0] in dl, ('{} is not exist in {}'.format(ks[0], dl))
if
not
ks
[
0
]
in
dl
:
logger
.
warning
(
'A new filed ({}) detected!'
.
format
(
ks
[
0
],
dl
))
dl
[
ks
[
0
]]
=
str2num
(
v
)
else
:
assert
ks
[
0
]
in
dl
,
(
'({}) doesn
\'
t exist in {}, a new dict field is invalid'
.
format
(
ks
[
0
],
dl
))
override
(
dl
[
ks
[
0
]],
ks
[
1
:],
v
)
...
...
tools/eval.py
浏览文件 @
d3bad33f
...
...
@@ -74,7 +74,7 @@ def main(args):
compiled_valid_prog
=
program
.
compile
(
config
,
valid_prog
)
program
.
run
(
valid_dataloader
,
exe
,
compiled_valid_prog
,
valid_fetchs
,
-
1
,
'eval'
)
'eval'
,
config
)
if
__name__
==
'__main__'
:
...
...
tools/program.py
浏览文件 @
d3bad33f
...
...
@@ -410,6 +410,7 @@ def run(dataloader,
fetchs
,
epoch
=
0
,
mode
=
'train'
,
config
=
None
,
vdl_writer
=
None
):
"""
Feed data to the model and fetch the measures and loss
...
...
@@ -443,16 +444,28 @@ def run(dataloader,
logger
.
scaler
(
'loss'
,
metrics
[
0
][
0
],
total_step
,
vdl_writer
)
total_step
+=
1
if
mode
==
'eval'
:
logger
.
info
(
"{:s} step:{:<4d} {:s}s"
.
format
(
mode
,
idx
,
fetchs_str
))
if
idx
%
config
.
get
(
'print_interval'
,
1
)
==
0
:
logger
.
info
(
"{:s} step:{:<4d} {:s}s"
.
format
(
mode
,
idx
,
fetchs_str
))
else
:
epoch_str
=
"epoch:{:<3d}"
.
format
(
epoch
)
step_str
=
"{:s} step:{:<4d}"
.
format
(
mode
,
idx
)
logger
.
info
(
"{:s} {:s} {:s}"
.
format
(
logger
.
coloring
(
epoch_str
,
"HEADER"
)
if
idx
==
0
else
epoch_str
,
logger
.
coloring
(
step_str
,
"PURPLE"
),
logger
.
coloring
(
fetchs_str
,
'OKGREEN'
)))
# Keep the first 10 batches statistics, They are important for develop
if
epoch
==
0
and
idx
<
10
:
logger
.
info
(
"{:s} {:s} {:s}"
.
format
(
logger
.
coloring
(
epoch_str
,
"HEADER"
)
if
idx
==
0
else
epoch_str
,
logger
.
coloring
(
step_str
,
"PURPLE"
),
logger
.
coloring
(
fetchs_str
,
'OKGREEN'
)))
else
:
if
idx
%
config
.
get
(
'print_interval'
,
1
)
==
0
:
logger
.
info
(
"{:s} {:s} {:s}"
.
format
(
logger
.
coloring
(
epoch_str
,
"HEADER"
)
if
idx
==
0
else
epoch_str
,
logger
.
coloring
(
step_str
,
"PURPLE"
),
logger
.
coloring
(
fetchs_str
,
'OKGREEN'
)))
end_str
=
''
.
join
([
str
(
m
.
mean
)
+
' '
for
m
in
metric_list
]
+
[
batch_time
.
total
])
+
's'
...
...
tools/run.sh
浏览文件 @
d3bad33f
...
...
@@ -5,4 +5,5 @@ export PYTHONPATH=$PWD:$PYTHONPATH
python
-m
paddle.distributed.launch
\
--selected_gpus
=
"0,1,2,3"
\
tools/train.py
\
-c
./configs/ResNet/ResNet50.yaml
-c
./configs/ResNet/ResNet50.yaml
\
-o
print_interval
=
10
tools/train.py
浏览文件 @
d3bad33f
...
...
@@ -110,21 +110,21 @@ def main(args):
for
epoch_id
in
range
(
config
.
epochs
):
# 1. train with train dataset
program
.
run
(
train_dataloader
,
exe
,
compiled_train_prog
,
train_fetchs
,
epoch_id
,
'train'
,
vdl_writer
)
epoch_id
,
'train'
,
config
,
vdl_writer
)
if
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
0
))
==
0
:
# 2. validate with validate dataset
if
config
.
validate
and
epoch_id
%
config
.
valid_interval
==
0
:
if
config
.
get
(
'use_ema'
):
logger
.
info
(
logger
.
coloring
(
"EMA validate start..."
))
with
ema
.
apply
(
exe
):
top1_acc
=
program
.
run
(
valid_dataloader
,
exe
,
compiled_valid_prog
,
valid_fetchs
,
epoch_id
,
'valid'
)
top1_acc
=
program
.
run
(
valid_dataloader
,
exe
,
compiled_valid_prog
,
valid_fetchs
,
epoch_id
,
'valid'
,
config
)
logger
.
info
(
logger
.
coloring
(
"EMA validate over!"
))
top1_acc
=
program
.
run
(
valid_dataloader
,
exe
,
compiled_valid_prog
,
valid_fetchs
,
epoch_id
,
'valid'
)
epoch_id
,
'valid'
,
config
)
if
top1_acc
>
best_top1_acc
:
best_top1_acc
=
top1_acc
message
=
"The best top1 acc {:.5f}, in epoch: {:d}"
.
format
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录