Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
7310baa8
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7310baa8
编写于
8月 09, 2017
作者:
Y
Yang yaming
提交者:
GitHub
8月 09, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #193 from pkuyym/error_rate_optional
Make type of error rate optional.
上级
c7f57e50
43f4f83d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
8 deletion
+29
-8
deep_speech_2/evaluate.py
deep_speech_2/evaluate.py
+16
-5
deep_speech_2/infer.py
deep_speech_2/infer.py
+12
-2
deep_speech_2/model.py
deep_speech_2/model.py
+1
-1
未找到文件。
deep_speech_2/evaluate.py
浏览文件 @
7310baa8
...
...
@@ -9,7 +9,7 @@ import multiprocessing
import
paddle.v2
as
paddle
from
data_utils.data
import
DataGenerator
from
model
import
DeepSpeech2Model
from
error_rate
import
wer
from
error_rate
import
wer
,
cer
import
utils
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
...
...
@@ -111,6 +111,14 @@ parser.add_argument(
default
=
'datasets/vocab/eng_vocab.txt'
,
type
=
str
,
help
=
"Vocabulary filepath. (default: %(default)s)"
)
parser
.
add_argument
(
"--error_rate_type"
,
default
=
'wer'
,
choices
=
[
'wer'
,
'cer'
],
type
=
str
,
help
=
"Error rate type for evaluation. 'wer' for word error rate and 'cer' "
"for character error rate. "
"(default: %(default)s)"
)
args
=
parser
.
parse_args
()
...
...
@@ -136,7 +144,8 @@ def evaluate():
rnn_layer_size
=
args
.
rnn_layer_size
,
pretrained_model_path
=
args
.
model_filepath
)
wer_sum
,
num_ins
=
0.0
,
0
error_rate_func
=
cer
if
args
.
error_rate_type
==
'cer'
else
wer
error_sum
,
num_ins
=
0.0
,
0
for
infer_data
in
batch_reader
():
result_transcripts
=
ds2_model
.
infer_batch
(
infer_data
=
infer_data
,
...
...
@@ -153,10 +162,12 @@ def evaluate():
for
_
,
transcript
in
infer_data
]
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
wer_sum
+=
wer
(
target
,
result
)
error_sum
+=
error_rate_func
(
target
,
result
)
num_ins
+=
1
print
(
"WER (%d/?) = %f"
%
(
num_ins
,
wer_sum
/
num_ins
))
print
(
"Final WER (%d/%d) = %f"
%
(
num_ins
,
num_ins
,
wer_sum
/
num_ins
))
print
(
"Error rate [%s] (%d/?) = %f"
%
(
args
.
error_rate_type
,
num_ins
,
error_sum
/
num_ins
))
print
(
"Final error rate [%s] (%d/%d) = %f"
%
(
args
.
error_rate_type
,
num_ins
,
num_ins
,
error_sum
/
num_ins
))
def
main
():
...
...
deep_speech_2/infer.py
浏览文件 @
7310baa8
...
...
@@ -9,7 +9,7 @@ import multiprocessing
import
paddle.v2
as
paddle
from
data_utils.data
import
DataGenerator
from
model
import
DeepSpeech2Model
from
error_rate
import
wer
from
error_rate
import
wer
,
cer
import
utils
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
...
...
@@ -111,6 +111,14 @@ parser.add_argument(
type
=
float
,
help
=
"The cutoff probability of pruning"
"in beam search. (default: %(default)f)"
)
parser
.
add_argument
(
"--error_rate_type"
,
default
=
'wer'
,
choices
=
[
'wer'
,
'cer'
],
type
=
str
,
help
=
"Error rate type for evaluation. 'wer' for word error rate and 'cer' "
"for character error rate. "
"(default: %(default)s)"
)
args
=
parser
.
parse_args
()
...
...
@@ -147,6 +155,7 @@ def infer():
language_model_path
=
args
.
language_model_path
,
num_processes
=
args
.
num_processes_beam_search
)
error_rate_func
=
cer
if
args
.
error_rate_type
==
'cer'
else
wer
target_transcripts
=
[
''
.
join
([
data_generator
.
vocab_list
[
token
]
for
token
in
transcript
])
for
_
,
transcript
in
infer_data
...
...
@@ -154,7 +163,8 @@ def infer():
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
print
(
"
\n
Target Transcription: %s
\n
Output Transcription: %s"
%
(
target
,
result
))
print
(
"Current wer = %f"
%
wer
(
target
,
result
))
print
(
"Current error rate [%s] = %f"
%
(
args
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
def
main
():
...
...
deep_speech_2/model.py
浏览文件 @
7310baa8
...
...
@@ -185,7 +185,7 @@ class DeepSpeech2Model(object):
# best path decode
for
i
,
probs
in
enumerate
(
probs_split
):
output_transcription
=
ctc_best_path_decoder
(
probs_seq
=
probs
,
vocabulary
=
data_generator
.
vocab_list
)
probs_seq
=
probs
,
vocabulary
=
vocab_list
)
results
.
append
(
output_transcription
)
elif
decode_method
==
"beam_search"
:
# initialize external scorer
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录