Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
cfe9d228
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看板
提交
cfe9d228
编写于
6月 04, 2017
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update annotations
上级
c943ca79
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
18 deletion
+36
-18
ctc_beam_search_decoder.py
ctc_beam_search_decoder.py
+36
-18
未找到文件。
ctc_beam_search_decoder.py
浏览文件 @
cfe9d228
...
...
@@ -10,12 +10,6 @@ import numpy as np
vocab
=
[
'-'
,
'_'
,
'a'
]
def
ids_str2list
(
ids_str
):
ids_str
=
ids_str
.
split
(
' '
)
ids_list
=
[
int
(
elem
)
for
elem
in
ids_str
]
return
ids_list
def
ids_list2str
(
ids_list
):
ids_str
=
[
str
(
elem
)
for
elem
in
ids_list
]
ids_str
=
' '
.
join
(
ids_str
)
...
...
@@ -39,21 +33,45 @@ def ctc_beam_search_decoder(input_probs_matrix,
space_id
=
1
,
num_results_per_sample
=
None
):
'''
beam search decoder for CTC-trained network, called outside of the recurrent group.
adapted from Algorithm 1 in https://arxiv.org/abs/1408.2873.
Beam search decoder for CTC-trained network, adapted from Algorithm 1
in https://arxiv.org/abs/1408.2873.
:param input_probs_matrix: probs matrix for input sequence, row major
:type input_probs_matrix: 2D matrix.
:param beam_size: width for beam search
:type beam_size: int
:max_time_steps: maximum steps' number for input sequence,
<=len(input_probs_matrix)
:type max_time_steps: int
:lang_model: language model for scoring
:type lang_model: function
:param alpha: parameter associated with language model.
:type alpha: float
:param beta: parameter associated with word count
:type beta: float
:param blank_id: id of blank, default 0.
:type blank_id: int
:param space_id: id of space, default 1.
:type space_id: int
:param num_result_per_sample: the number of output decoding results
per given sample, <=beam_size.
:type num_result_per_sample: int
'''
param input_probs_matrix: probs matrix for input sequence, row major
type input_probs_matrix: 2D matrix.
param beam_size: width for beam search
type beam_size: int
max_time_steps: maximum steps' number for input sequence, <=len(input_probs_matrix)
type max_time_steps: int
lang_model: language model for scoring
type lang_model: function
# function to convert ids in string to list
def
ids_str2list
(
ids_str
):
ids_str
=
ids_str
.
split
(
' '
)
ids_list
=
[
int
(
elem
)
for
elem
in
ids_str
]
return
ids_list
......
# counting words in a character list
def
word_count
(
ids_list
):
cnt
=
0
for
elem
in
ids_list
:
if
elem
==
space_id
:
cnt
+=
1
return
cnt
'''
if
num_results_per_sample
is
None
:
num_results_per_sample
=
beam_size
assert
num_results_per_sample
<=
beam_size
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录