Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
e6e7b132
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e6e7b132
编写于
9月 25, 2017
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove the log praser in tuning script
上级
4c64841c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
30 addition
and
48 deletion
+30
-48
examples/librispeech/run_tune.sh
examples/librispeech/run_tune.sh
+5
-5
examples/tiny/run_tune.sh
examples/tiny/run_tune.sh
+10
-8
tools/tune.py
tools/tune.py
+15
-35
未找到文件。
examples/librispeech/run_tune.sh
浏览文件 @
e6e7b132
...
@@ -3,18 +3,18 @@
...
@@ -3,18 +3,18 @@
pushd
../..
>
/dev/null
pushd
../..
>
/dev/null
# grid-search for hyper-parameters in language model
# grid-search for hyper-parameters in language model
CUDA_VISIBLE_DEVICES
=
0,1,2,3
,4,5,6,7
\
CUDA_VISIBLE_DEVICES
=
0,1,2,3
\
python
-u
tools/tune.py
\
python
-u
tools/tune.py
\
--num_batches
=
2
\
--num_batches
=
-1
\
--batch_size
=
2
4
\
--batch_size
=
2
56
\
--trainer_count
=
8
\
--trainer_count
=
8
\
--beam_size
=
500
\
--beam_size
=
500
\
--num_proc_bsearch
=
12
\
--num_proc_bsearch
=
12
\
--num_conv_layers
=
2
\
--num_conv_layers
=
2
\
--num_rnn_layers
=
3
\
--num_rnn_layers
=
3
\
--rnn_layer_size
=
2048
\
--rnn_layer_size
=
2048
\
--num_alphas
=
2
\
--num_alphas
=
45
\
--num_betas
=
2
\
--num_betas
=
8
\
--alpha_from
=
1.0
\
--alpha_from
=
1.0
\
--alpha_to
=
3.2
\
--alpha_to
=
3.2
\
--beta_from
=
0.1
\
--beta_from
=
0.1
\
...
...
examples/tiny/run_tune.sh
浏览文件 @
e6e7b132
...
@@ -5,20 +5,22 @@ pushd ../.. > /dev/null
...
@@ -5,20 +5,22 @@ pushd ../.. > /dev/null
# grid-search for hyper-parameters in language model
# grid-search for hyper-parameters in language model
CUDA_VISIBLE_DEVICES
=
0,1,2,3,4,5,6,7
\
CUDA_VISIBLE_DEVICES
=
0,1,2,3,4,5,6,7
\
python
-u
tools/tune.py
\
python
-u
tools/tune.py
\
--num_samples
=
100
\
--num_batches
=
1
\
--batch_size
=
24
\
--trainer_count
=
8
\
--trainer_count
=
8
\
--beam_size
=
500
\
--beam_size
=
500
\
--num_proc_bsearch
=
12
\
--num_proc_bsearch
=
12
\
--num_conv_layers
=
2
\
--num_conv_layers
=
2
\
--num_rnn_layers
=
3
\
--num_rnn_layers
=
3
\
--rnn_layer_size
=
2048
\
--rnn_layer_size
=
2048
\
--num_alphas
=
14
\
--num_alphas
=
45
\
--num_betas
=
20
\
--num_betas
=
8
\
--alpha_from
=
0.1
\
--alpha_from
=
1.0
\
--alpha_to
=
0.36
\
--alpha_to
=
3.2
\
--beta_from
=
0.05
\
--beta_from
=
0.1
\
--beta_to
=
1.0
\
--beta_to
=
0.45
\
--cutoff_prob
=
0.99
\
--cutoff_prob
=
1.0
\
--cutoff_top_n
=
40
\
--use_gru
=
False
\
--use_gru
=
False
\
--use_gpu
=
True
\
--use_gpu
=
True
\
--share_rnn_weights
=
True
\
--share_rnn_weights
=
True
\
...
...
tools/tune.py
浏览文件 @
e6e7b132
...
@@ -34,7 +34,6 @@ add_arg('beta_from', float, 0.1, "Where beta starts tuning from.")
...
@@ -34,7 +34,6 @@ add_arg('beta_from', float, 0.1, "Where beta starts tuning from.")
add_arg
(
'beta_to'
,
float
,
0.45
,
"Where beta ends tuning with."
)
add_arg
(
'beta_to'
,
float
,
0.45
,
"Where beta ends tuning with."
)
add_arg
(
'cutoff_prob'
,
float
,
1.0
,
"Cutoff probability for pruning."
)
add_arg
(
'cutoff_prob'
,
float
,
1.0
,
"Cutoff probability for pruning."
)
add_arg
(
'cutoff_top_n'
,
int
,
40
,
"Cutoff number for pruning."
)
add_arg
(
'cutoff_top_n'
,
int
,
40
,
"Cutoff number for pruning."
)
add_arg
(
'output_fig'
,
bool
,
True
,
"Output error rate figure or not."
)
add_arg
(
'use_gru'
,
bool
,
False
,
"Use GRUs instead of simple RNNs."
)
add_arg
(
'use_gru'
,
bool
,
False
,
"Use GRUs instead of simple RNNs."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Use GPU or not."
)
add_arg
(
'use_gpu'
,
bool
,
True
,
"Use GPU or not."
)
add_arg
(
'share_rnn_weights'
,
bool
,
True
,
"Share input-hidden weights across "
add_arg
(
'share_rnn_weights'
,
bool
,
True
,
"Share input-hidden weights across "
...
@@ -66,26 +65,9 @@ add_arg('specgram_type', str,
...
@@ -66,26 +65,9 @@ add_arg('specgram_type', str,
# yapf: disable
# yapf: disable
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
def
plot_error_surface
(
params_grid
,
err_ave
,
fig_name
):
import
matplotlib.pyplot
as
plt
import
mpl_toolkits.mplot3d
as
Axes3D
fig
=
plt
.
figure
()
ax
=
Axes3D
(
fig
)
alphas
=
[
param
[
0
]
for
param
in
params_grid
]
betas
=
[
param
[
1
]
for
param
in
params_grid
]
ALPHAS
=
np
.
reshape
(
alphas
,
(
args
.
num_alphas
,
args
.
num_betas
))
BETAS
=
np
.
reshape
(
betas
,
(
args
.
num_alphas
,
args
.
num_betas
))
ERR_AVE
=
np
.
reshape
(
err_ave
,
(
args
.
num_alphas
,
args
.
num_betas
))
ax
.
plot_surface
(
ALPHAS
,
BETAS
,
WERS
,
rstride
=
1
,
cstride
=
1
,
alpha
=
0.8
,
cmap
=
'rainbow'
)
ax
.
set_xlabel
(
'alpha'
)
ax
.
set_ylabel
(
'beta'
)
z_label
=
'WER'
if
args
.
error_rate_type
==
'wer'
else
'CER'
ax
.
set_zlabel
(
z_label
)
plt
.
savefig
(
fig_name
)
def
tune
():
def
tune
():
"""Tune parameters alpha and beta
on one minibatch
."""
"""Tune parameters alpha and beta
incrementally
."""
if
not
args
.
num_alphas
>=
0
:
if
not
args
.
num_alphas
>=
0
:
raise
ValueError
(
"num_alphas must be non-negative!"
)
raise
ValueError
(
"num_alphas must be non-negative!"
)
if
not
args
.
num_betas
>=
0
:
if
not
args
.
num_betas
>=
0
:
...
@@ -160,38 +142,36 @@ def tune():
...
@@ -160,38 +142,36 @@ def tune():
err_ave
[
index
]
=
err_sum
[
index
]
/
num_ins
err_ave
[
index
]
=
err_sum
[
index
]
/
num_ins
# print("alpha = %f, beta = %f, WER = %f" %
# print("alpha = %f, beta = %f, WER = %f" %
# (alpha, beta, err_ave[index]))
# (alpha, beta, err_ave[index]))
if
index
%
10
==
0
:
if
index
%
2
==
0
:
sys
.
stdout
.
write
(
'.'
)
sys
.
stdout
.
write
(
'.'
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
# output on-line tuning result at the the end of current batch
# output on-line tuning result at the the end of current batch
err_ave_min
=
min
(
err_ave
)
err_ave_min
=
min
(
err_ave
)
min_index
=
err_ave
.
index
(
err_ave_min
)
min_index
=
err_ave
.
index
(
err_ave_min
)
print
(
"
\n
Batch %d, opt.(alpha, beta) = (%f, %f), min. error_rate = %f"
print
(
"
\n
Batch %d [%d/?], current opt (alpha, beta) = (%s, %s), "
%
(
cur_batch
,
params_grid
[
min_index
][
0
],
" min [%s] = %f"
%
(
cur_batch
,
num_ins
,
params_grid
[
min_index
][
1
],
err_ave_min
))
"%.3f"
%
params_grid
[
min_index
][
0
],
"%.3f"
%
params_grid
[
min_index
][
1
],
args
.
error_rate_type
,
err_ave_min
))
cur_batch
+=
1
cur_batch
+=
1
# output WER/CER at every point
# output WER/CER at every point
print
(
"
\n
error rate at each point:
\n
"
)
print
(
"
\n
Final %s:
\n
"
%
args
.
error_rate_type
)
for
index
in
xrange
(
len
(
params_grid
)):
for
index
in
xrange
(
len
(
params_grid
)):
print
(
"(%f, %f), error_rate = %f"
print
(
"(alpha, beta) = (%s, %s), [%s] = %f"
%
(
params_grid
[
index
][
0
],
params_grid
[
index
][
1
],
err_ave
[
index
]))
%
(
"%.3f"
%
params_grid
[
index
][
0
],
"%.3f"
%
params_grid
[
index
][
1
],
args
.
error_rate_type
,
err_ave
[
index
]))
err_ave_min
=
min
(
err_ave
)
err_ave_min
=
min
(
err_ave
)
min_index
=
err_ave
.
index
(
err_ave_min
)
min_index
=
err_ave
.
index
(
err_ave_min
)
print
(
"
\n
Tuning on %d batches, opt. (alpha, beta) = (%f, %f)"
print
(
"
\n
Finish tuning on %d batches, final opt (alpha, beta) = (%s, %s)"
%
(
args
.
num_batches
,
params_grid
[
min_index
][
0
],
%
(
args
.
num_batches
,
"%.3f"
%
params_grid
[
min_index
][
0
],
params_grid
[
min_index
][
1
]))
"%.3f"
%
params_grid
[
min_index
][
1
]))
if
args
.
output_fig
==
True
:
fig_name
=
(
"error_surface_alphas_%d_betas_%d"
%
(
args
.
num_alphas
,
args
.
num_betas
))
plot_error_surface
(
params_grid
,
err_ave
,
fig_name
)
ds2_model
.
logger
.
info
(
"output figure %s"
%
fig_name
)
ds2_model
.
logger
.
info
(
"finish inference"
)
ds2_model
.
logger
.
info
(
"finish inference"
)
def
main
():
def
main
():
print_arguments
(
args
)
print_arguments
(
args
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
args
.
trainer_count
)
paddle
.
init
(
use_gpu
=
args
.
use_gpu
,
trainer_count
=
args
.
trainer_count
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录