Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
808206a4
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
接近 2 年 前同步成功
通知
284
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
808206a4
编写于
9月 23, 2019
作者:
Z
zhangxuefei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update autofinetune and run command
上级
1bc44e50
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
7 deletion
+36
-7
paddlehub/autofinetune/evaluator.py
paddlehub/autofinetune/evaluator.py
+22
-2
paddlehub/commands/run.py
paddlehub/commands/run.py
+9
-1
paddlehub/io/parser.py
paddlehub/io/parser.py
+3
-2
tutorial/autofinetune.md
tutorial/autofinetune.md
+2
-2
未找到文件。
paddlehub/autofinetune/evaluator.py
浏览文件 @
808206a4
...
...
@@ -136,7 +136,17 @@ class FullTrailEvaluator(BaseEvaluator):
os
.
system
(
run_cmd
)
with
open
(
log_file
,
"r"
)
as
f
:
lines
=
f
.
readlines
()
eval_result
=
float
(
lines
[
-
1
])
eval_result
=
[]
for
line
in
lines
:
line
=
line
.
strip
()
if
line
.
startswith
(
"AutoFinetuneEval"
):
data
=
line
.
split
(
"
\t
"
)
eval_result
=
float
(
data
[
-
1
])
if
eval_result
==
[]:
print
(
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
%
param_str
.
replace
(
"--"
,
""
))
eval_result
=
0.0
except
:
print
(
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
...
...
@@ -190,7 +200,17 @@ class ModelBasedEvaluator(BaseEvaluator):
os
.
system
(
run_cmd
)
with
open
(
log_file
,
"r"
)
as
f
:
lines
=
f
.
readlines
()
eval_result
=
float
(
lines
[
-
1
])
eval_result
=
[]
for
line
in
lines
:
line
=
line
.
strip
()
if
line
.
startswith
(
"AutoFinetuneEval"
):
data
=
line
.
split
(
"
\t
"
)
eval_result
=
float
(
data
[
-
1
])
if
eval_result
==
[]:
print
(
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
%
param_str
.
replace
(
"--"
,
""
))
eval_result
=
0.0
except
:
print
(
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
...
...
paddlehub/commands/run.py
浏览文件 @
808206a4
...
...
@@ -108,6 +108,13 @@ class RunCommand(BaseCommand):
type
=
str
,
default
=
None
,
help
=
"file contain input data"
)
self
.
arg_input_group
.
add_argument
(
'--use_strip'
,
type
=
ast
.
literal_eval
,
default
=
True
,
help
=
"whether need to strip whitespace characters from the beginning and the end of the line in the file or not."
)
if
len
(
expect_data_format
)
==
1
:
if
module_type
.
startswith
(
"cv"
):
self
.
arg_input_group
.
add_argument
(
...
...
@@ -147,7 +154,8 @@ class RunCommand(BaseCommand):
if
len
(
expect_data_format
)
==
1
:
key
=
list
(
expect_data_format
.
keys
())[
0
]
if
self
.
args
.
input_file
:
input_data
[
key
]
=
txt_parser
.
parse
(
self
.
args
.
input_file
)
input_data
[
key
]
=
txt_parser
.
parse
(
self
.
args
.
input_file
,
self
.
args
.
use_strip
)
else
:
if
module_type
.
startswith
(
"cv"
):
input_data
[
key
]
=
[
self
.
args
.
input_path
]
...
...
paddlehub/io/parser.py
浏览文件 @
808206a4
...
...
@@ -71,11 +71,12 @@ class TextFileParser(object):
def
_check
(
self
):
pass
def
parse
(
self
,
txt_file
):
def
parse
(
self
,
txt_file
,
use_strip
=
True
):
with
codecs
.
open
(
txt_file
,
"r"
,
sys_stdin_encoding
())
as
file
:
contents
=
[]
for
line
in
file
:
line
=
line
.
strip
()
if
use_strip
:
line
=
line
.
strip
()
if
line
:
contents
.
append
(
line
)
return
contents
...
...
tutorial/autofinetune.md
浏览文件 @
808206a4
...
...
@@ -163,7 +163,7 @@ if __name__ == '__main__':
shutil
.
copytree
(
config
.
checkpoint_dir
+
"/best_model/"
,
args
.
saved_params_dir
)
shutil
.
rmtree
(
config
.
checkpoint_dir
)
print
(
eval_avg_score
[
"acc"
],
end
=
""
)
print
(
"AutoFinetuneEval"
+
"
\t
"
+
str
(
float
(
eval_avg_score
[
"acc"
]))
)
```
**Note**
:以上是finetunee.py的写法。
> finetunee.py必须可以接收待优化超参数选项参数, 并且待搜素超参数选项名字和yaml文件中的超参数名字保持一致.
...
...
@@ -174,7 +174,7 @@ if __name__ == '__main__':
> PaddleHub Auto Fine-tune优化超参策略选择hazero时,必须提供两个以上的待优化超参。
> finetunee.py
的最后一个输出必须是模型在数据集dev上的评价效果,同时以“”结束,如print(eval_avg_score["acc"], end=""
).
> finetunee.py
必须输出模型在数据集dev上的评价效果,同时以“AutoFinetuneEval"开始,和评价效果之间以“\t”分开,如print("AutoFinetuneEval"+"\t"+str(float(eval_avg_score["acc"]))
).
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录