Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
43f4f83d
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看板
提交
43f4f83d
编写于
8月 09, 2017
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify description and codes.
上级
8e9f6cde
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
14 addition
and
28 deletion
+14
-28
deep_speech_2/evaluate.py
deep_speech_2/evaluate.py
+8
-15
deep_speech_2/infer.py
deep_speech_2/infer.py
+6
-13
未找到文件。
deep_speech_2/evaluate.py
浏览文件 @
43f4f83d
...
...
@@ -9,8 +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
cer
from
error_rate
import
wer
,
cer
import
utils
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
...
...
@@ -117,8 +116,8 @@ parser.add_argument(
default
=
'wer'
,
choices
=
[
'wer'
,
'cer'
],
type
=
str
,
help
=
"
There are total two error rate types including wer and cer. wer
"
"
represents for word error rate while cer
for character error rate. "
help
=
"
Error rate type for evaluation. 'wer' for word error rate and 'cer'
"
"for character error rate. "
"(default: %(default)s)"
)
args
=
parser
.
parse_args
()
...
...
@@ -145,13 +144,7 @@ def evaluate():
rnn_layer_size
=
args
.
rnn_layer_size
,
pretrained_model_path
=
args
.
model_filepath
)
if
args
.
error_rate_type
==
'wer'
:
error_rate_func
=
wer
error_rate_info
=
'WER'
else
:
error_rate_func
=
cer
error_rate_info
=
'CER'
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
(
...
...
@@ -171,10 +164,10 @@ def evaluate():
for
target
,
result
in
zip
(
target_transcripts
,
result_transcripts
):
error_sum
+=
error_rate_func
(
target
,
result
)
num_ins
+=
1
print
(
"
%s (%d/?) = %f"
%
\
(
error_rate_info
,
num_ins
,
error_sum
/
num_ins
))
print
(
"Final
%s (%d/%d) = %f"
%
\
(
error_rate_info
,
num_ins
,
num_ins
,
error_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
浏览文件 @
43f4f83d
...
...
@@ -9,8 +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
cer
from
error_rate
import
wer
,
cer
import
utils
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
)
...
...
@@ -117,8 +116,8 @@ parser.add_argument(
default
=
'wer'
,
choices
=
[
'wer'
,
'cer'
],
type
=
str
,
help
=
"
There are total two error rate types including wer and cer. wer
"
"
represents for word error rate while cer
for character error rate. "
help
=
"
Error rate type for evaluation. 'wer' for word error rate and 'cer'
"
"for character error rate. "
"(default: %(default)s)"
)
args
=
parser
.
parse_args
()
...
...
@@ -156,13 +155,7 @@ def infer():
language_model_path
=
args
.
language_model_path
,
num_processes
=
args
.
num_processes_beam_search
)
if
args
.
error_rate_type
==
'wer'
:
error_rate_func
=
wer
error_rate_info
=
'wer'
else
:
error_rate_func
=
cer
error_rate_info
=
'cer'
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
...
...
@@ -170,8 +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
%s = %f"
%
\
(
error_rate_info
,
error_rate_func
(
target
,
result
)))
print
(
"Current
error rate [%s] = %f"
%
(
args
.
error_rate_type
,
error_rate_func
(
target
,
result
)))
def
main
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录