Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
279a2e03
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看板
提交
279a2e03
编写于
5月 17, 2022
作者:
W
weisy11
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add search_times
上级
047ec1ae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
10 deletion
+21
-10
ppcls/configs/StrategySearch/person.yaml
ppcls/configs/StrategySearch/person.yaml
+2
-0
tools/search_strategy.py
tools/search_strategy.py
+19
-10
未找到文件。
ppcls/configs/StrategySearch/person.yaml
浏览文件 @
279a2e03
...
...
@@ -3,6 +3,7 @@ distill_config_file: ppcls/configs/cls_demo/person/Distillation/PPLCNet_x1_0_dis
gpus
:
0,1,2,3
output_dir
:
output/search_person
search_times
:
3
search_dict
:
-
search_key
:
lrs
replace_config
:
...
...
@@ -27,6 +28,7 @@ search_dict:
search_values
:
-
[
0.0
,
0.2
,
0.4
,
0.6
,
0.8
,
1.0
]
-
[
0.0
,
0.4
,
0.4
,
0.8
,
0.8
,
1.0
]
-
[
1.0. 1.0. 1.0. 1.0. 1.0. 1.0
]
teacher
:
rm_keys
:
-
Arch.lr_mult_list
...
...
tools/search_strategy.py
浏览文件 @
279a2e03
...
...
@@ -7,6 +7,8 @@ __dir__ = os.path.dirname(os.path.abspath(__file__))
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'../'
)))
import
subprocess
import
numpy
as
np
from
ppcls.utils
import
config
...
...
@@ -18,7 +20,8 @@ def get_result(log_dir):
return
res
def
search_train
(
search_list
,
base_program
,
base_output_dir
,
search_key
,
config_replace_value
,
model_name
):
def
search_train
(
search_list
,
base_program
,
base_output_dir
,
search_key
,
config_replace_value
,
model_name
,
search_times
=
1
):
best_res
=
0.
best
=
search_list
[
0
]
all_result
=
{}
...
...
@@ -28,15 +31,19 @@ def search_train(search_list, base_program, base_output_dir, search_key, config_
program
+=
[
"-o"
,
"{}={}"
.
format
(
v
,
search_i
)]
if
v
==
"Arch.name"
:
model_name
=
search_i
output_dir
=
"{}/{}_{}"
.
format
(
base_output_dir
,
search_key
,
search_i
).
replace
(
"."
,
"_"
)
program
+=
[
"-o"
,
"Global.output_dir={}"
.
format
(
output_dir
)]
process
=
subprocess
.
Popen
(
program
)
process
.
communicate
()
res
=
get_result
(
"{}/{}"
.
format
(
output_dir
,
model_name
))
all_result
[
str
(
search_i
)]
=
res
if
res
>
best_res
:
res_list
=
[]
for
j
in
range
(
search_times
):
output_dir
=
"{}/{}_{}_{}"
.
format
(
base_output_dir
,
search_key
,
search_i
,
j
).
replace
(
"."
,
"_"
)
program
+=
[
"-o"
,
"Global.output_dir={}"
.
format
(
output_dir
)]
process
=
subprocess
.
Popen
(
program
)
process
.
communicate
()
res
=
get_result
(
"{}/{}"
.
format
(
output_dir
,
model_name
))
res_list
.
append
(
res
)
all_result
[
str
(
search_i
)]
=
res_list
if
np
.
mean
(
res_list
)
>
best_res
:
best
=
search_i
best_res
=
res
best_res
=
np
.
mean
(
res_list
)
all_result
[
"best"
]
=
best
return
all_result
...
...
@@ -52,13 +59,15 @@ def search_strategy():
base_program
=
[
"python3.7"
,
"-m"
,
"paddle.distributed.launch"
,
"--gpus={}"
.
format
(
gpus
),
"tools/train.py"
,
"-c"
,
base_config_file
]
base_output_dir
=
configs
[
"output_dir"
]
search_times
=
configs
[
"search_times"
]
search_dict
=
configs
.
get
(
"search_dict"
)
all_results
=
{}
for
search_i
in
search_dict
:
search_key
=
search_i
[
"search_key"
]
search_values
=
search_i
[
"search_values"
]
replace_config
=
search_i
[
"replace_config"
]
res
=
search_train
(
search_values
,
base_program
,
base_output_dir
,
search_key
,
replace_config
,
model_name
)
res
=
search_train
(
search_values
,
base_program
,
base_output_dir
,
search_key
,
replace_config
,
model_name
,
search_times
)
all_results
[
search_key
]
=
res
best
=
res
.
get
(
"best"
)
for
v
in
replace_config
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录