Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
1f117410
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
1 年多 前同步成功
通知
283
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看板
提交
1f117410
编写于
12月 16, 2019
作者:
S
Steffy-zxf
提交者:
wuzewu
12月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix path bug (#261)
* fix path bug * fix environment variable autodl setting
上级
98e6c96d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
34 deletion
+30
-34
paddlehub/autofinetune/autoft.py
paddlehub/autofinetune/autoft.py
+2
-1
paddlehub/autofinetune/evaluator.py
paddlehub/autofinetune/evaluator.py
+28
-33
未找到文件。
paddlehub/autofinetune/autoft.py
浏览文件 @
1f117410
...
...
@@ -201,7 +201,8 @@ class BaseTuningStrategy(object):
self
.
feedback
(
solutions
,
solution_results
)
# remove the tmp.txt which records the eval results for trials
tmp_file
=
os
.
path
.
join
(
TMP_HOME
,
"tmp.txt"
)
os
.
remove
(
tmp_file
)
if
os
.
path
.
exists
(
tmp_file
):
os
.
remove
(
tmp_file
)
return
solutions_modeldirs
...
...
paddlehub/autofinetune/evaluator.py
浏览文件 @
1f117410
...
...
@@ -21,6 +21,7 @@ import hashlib
import
math
import
os
import
random
import
string
import
six
import
yaml
...
...
@@ -42,17 +43,12 @@ def report_final_result(result):
# tmp.txt is to record the eval results for trials
mkdir
(
TMP_HOME
)
tmp_file
=
os
.
path
.
join
(
TMP_HOME
,
"tmp.txt"
)
with
open
(
tmp_file
,
'a'
)
as
f
ile
:
f
ile
.
write
(
trial_id
+
"
\t
"
+
str
(
float
(
result
))
+
"
\n
"
)
with
open
(
tmp_file
,
'a'
)
as
f
:
f
.
write
(
trial_id
+
"
\t
"
+
str
(
float
(
result
))
+
"
\n
"
)
def
unique_name
():
seed
=
"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+=-"
x
=
[]
for
idx
in
range
(
4
):
x
.
append
(
random
.
choice
(
seed
))
rand_str
=
""
.
join
(
x
)
return
rand_str
return
''
.
join
(
random
.
sample
(
string
.
ascii_letters
+
string
.
digits
,
8
))
class
BaseEvaluator
(
object
):
...
...
@@ -146,18 +142,17 @@ class FullTrailEvaluator(BaseEvaluator):
f
=
open
(
log_file
,
"w"
)
f
.
close
()
# set temp environment variable to record the eval results for trials
rand_str
=
unique_name
()
if
is_windows
():
run_cmd
=
"set FLAGS_eager_delete_tensor_gb=0.0&set CUDA_VISIBLE_DEVICES=%s&python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
run_cmd
=
"set
PaddleHub_AutoDL_Trial_ID=%s&set
FLAGS_eager_delete_tensor_gb=0.0&set CUDA_VISIBLE_DEVICES=%s&python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
rand_str
,
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
else
:
run_cmd
=
"export FLAGS_eager_delete_tensor_gb=0.0; export CUDA_VISIBLE_DEVICES=%s; python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
run_cmd
=
"export
PaddleHub_AutoDL_Trial_ID=%s; export
FLAGS_eager_delete_tensor_gb=0.0; export CUDA_VISIBLE_DEVICES=%s; python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
rand_str
,
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
try
:
# set temp environment variable to record the eval results for trials
rand_str
=
unique_name
()
os
.
environ
[
'PaddleHub_AutoDL_Trial_ID'
]
=
rand_str
os
.
system
(
run_cmd
)
eval_result
=
[]
...
...
@@ -172,7 +167,7 @@ class FullTrailEvaluator(BaseEvaluator):
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
%
param_str
.
replace
(
"--"
,
""
))
eval_result
=
0.0
except
:
except
Exception
as
e
:
print
(
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
%
param_str
.
replace
(
"--"
,
""
))
...
...
@@ -203,37 +198,36 @@ class PopulationBasedEvaluator(BaseEvaluator):
f
=
open
(
log_file
,
"w"
)
f
.
close
()
# set temp environment variable to record the eval results for trials
rand_str
=
unique_name
()
if
len
(
self
.
half_best_model_path
)
>
0
:
model_path
=
self
.
half_best_model_path
[
self
.
run_count
%
len
(
self
.
half_best_model_path
)]
if
is_windows
():
run_cmd
=
"set FLAGS_eager_delete_tensor_gb=0.0&set CUDA_VISIBLE_DEVICES=%s&python -u %s --epochs=1 --model_path %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
num_cuda
,
self
.
finetunee_script
,
model_path
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
run_cmd
=
"set
PaddleHub_AutoDL_Trial_ID=%s&set
FLAGS_eager_delete_tensor_gb=0.0&set CUDA_VISIBLE_DEVICES=%s&python -u %s --epochs=1 --model_path %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
rand_str
,
num_cuda
,
self
.
finetunee_script
,
model_path
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
else
:
run_cmd
=
"export FLAGS_eager_delete_tensor_gb=0.0; export CUDA_VISIBLE_DEVICES=%s; python -u %s --epochs=1 --model_path %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
num_cuda
,
self
.
finetunee_script
,
model_path
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
run_cmd
=
"export
PaddleHub_AutoDL_Trial_ID=%s; export
FLAGS_eager_delete_tensor_gb=0.0; export CUDA_VISIBLE_DEVICES=%s; python -u %s --epochs=1 --model_path %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
rand_str
,
num_cuda
,
self
.
finetunee_script
,
model_path
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
else
:
if
is_windows
():
run_cmd
=
"set FLAGS_eager_delete_tensor_gb=0.0&set CUDA_VISIBLE_DEVICES=%s&python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
run_cmd
=
"set
PaddleHub_AutoDL_Trial_ID=%s&set
FLAGS_eager_delete_tensor_gb=0.0&set CUDA_VISIBLE_DEVICES=%s&python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
rand_str
,
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
else
:
run_cmd
=
"export FLAGS_eager_delete_tensor_gb=0.0; export CUDA_VISIBLE_DEVICES=%s; python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
run_cmd
=
"export
PaddleHub_AutoDL_Trial_ID=%s; export
FLAGS_eager_delete_tensor_gb=0.0; export CUDA_VISIBLE_DEVICES=%s; python -u %s --saved_params_dir=%s %s %s >%s 2>&1"
%
\
(
rand_str
,
num_cuda
,
self
.
finetunee_script
,
saved_params_dir
,
param_str
,
self
.
options_str
,
log_file
)
self
.
run_count
+=
1
try
:
# set temp environment variable to record the eval results for trials
rand_str
=
unique_name
()
os
.
environ
[
'PaddleHub_AutoDL_Trial_ID'
]
=
rand_str
os
.
system
(
run_cmd
)
eval_result
=
[]
tmp_file
=
os
.
join
.
path
(
TMP_HOME
,
'tmp.txt'
)
with
open
(
tmp_file
,
'r'
)
as
f
ile
:
for
line
in
f
ile
:
tmp_file
=
os
.
path
.
join
(
TMP_HOME
,
'tmp.txt'
)
with
open
(
tmp_file
,
'r'
)
as
f
:
for
line
in
f
:
data
=
line
.
strip
().
split
(
"
\t
"
)
if
rand_str
==
data
[
0
]:
eval_result
=
float
(
data
[
1
])
...
...
@@ -242,7 +236,8 @@ class PopulationBasedEvaluator(BaseEvaluator):
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
%
param_str
.
replace
(
"--"
,
""
))
eval_result
=
0.0
except
:
except
Exception
as
e
:
print
(
e
)
print
(
"WARNING: Program which was ran with hyperparameters as %s was crashed!"
%
param_str
.
replace
(
"--"
,
""
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录