Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
3a7a52e2
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看板
提交
3a7a52e2
编写于
6月 07, 2017
作者:
Y
Yibing Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename variables in decoder
上级
6698fe64
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
12 deletion
+13
-12
deep_speech_2/decoder.py
deep_speech_2/decoder.py
+13
-12
未找到文件。
deep_speech_2/decoder.py
浏览文件 @
3a7a52e2
...
...
@@ -92,7 +92,7 @@ def ctc_beam_search_decoder(probs_seq,
Search(https://arxiv.org/abs/1408.2873), and the unclear part is
redesigned, need to be verified.
:param probs_seq: 2-D list with length
max
_time_steps, each element
:param probs_seq: 2-D list with length
num
_time_steps, each element
is a list of normalized probabilities over vocabulary
and blank for one time step.
:type probs_seq: 2-D list
...
...
@@ -114,7 +114,7 @@ def ctc_beam_search_decoder(probs_seq,
for
prob_list
in
probs_seq
:
if
not
len
(
prob_list
)
==
len
(
vocabulary
)
+
1
:
raise
ValueError
(
"probs dimension mismatchedd with vocabulary"
)
max
_time_steps
=
len
(
probs_seq
)
num
_time_steps
=
len
(
probs_seq
)
# blank_id check
probs_dim
=
len
(
probs_seq
[
0
])
...
...
@@ -139,10 +139,10 @@ def ctc_beam_search_decoder(probs_seq,
## initialize
# the set containing selected prefixes
prefix_set_prev
=
{
'-1'
:
1.0
}
probs_b
,
probs_nb
=
{
'-1'
:
1.0
},
{
'-1'
:
0.0
}
probs_b
_prev
,
probs_nb_prev
=
{
'-1'
:
1.0
},
{
'-1'
:
0.0
}
## extend prefix in loop
for
time_step
in
range
(
max
_time_steps
):
for
time_step
in
range
(
num
_time_steps
):
# the set containing candidate prefixes
prefix_set_next
=
{}
probs_b_cur
,
probs_nb_cur
=
{},
{}
...
...
@@ -158,33 +158,34 @@ def ctc_beam_search_decoder(probs_seq,
# extend prefix by travering vocabulary
for
c
in
range
(
0
,
probs_dim
):
if
c
==
blank_id
:
probs_b_cur
[
l
]
+=
prob
[
c
]
*
(
probs_b
[
l
]
+
probs_nb
[
l
])
probs_b_cur
[
l
]
+=
prob
[
c
]
*
(
probs_b_prev
[
l
]
+
probs_nb_prev
[
l
])
else
:
l_plus
=
l
+
' '
+
str
(
c
)
if
not
prefix_set_next
.
has_key
(
l_plus
):
probs_b_cur
[
l_plus
],
probs_nb_cur
[
l_plus
]
=
0.0
,
0.0
if
c
==
end_id
:
probs_nb_cur
[
l_plus
]
+=
prob
[
c
]
*
probs_b
[
l
]
probs_nb_cur
[
l
]
+=
prob
[
c
]
*
probs_nb
[
l
]
probs_nb_cur
[
l_plus
]
+=
prob
[
c
]
*
probs_b
_prev
[
l
]
probs_nb_cur
[
l
]
+=
prob
[
c
]
*
probs_nb
_prev
[
l
]
elif
c
==
space_id
:
if
ext_scoring_func
is
None
:
score
=
1.0
else
:
prefix
_sent
=
ids2sentence
(
ids_list
,
vocabulary
)
score
=
ext_scoring_func
(
prefix
_sent
)
prefix
=
ids2sentence
(
ids_list
,
vocabulary
)
score
=
ext_scoring_func
(
prefix
)
probs_nb_cur
[
l_plus
]
+=
score
*
prob
[
c
]
*
(
probs_b
[
l
]
+
probs_nb
[
l
])
probs_b
_prev
[
l
]
+
probs_nb_prev
[
l
])
else
:
probs_nb_cur
[
l_plus
]
+=
prob
[
c
]
*
(
probs_b
[
l
]
+
probs_nb
[
l
])
probs_b
_prev
[
l
]
+
probs_nb_prev
[
l
])
# add l_plus into prefix_set_next
prefix_set_next
[
l_plus
]
=
probs_nb_cur
[
l_plus
]
+
probs_b_cur
[
l_plus
]
# add l into prefix_set_next
prefix_set_next
[
l
]
=
probs_b_cur
[
l
]
+
probs_nb_cur
[
l
]
# update probs
probs_b
,
probs_nb
=
copy
.
deepcopy
(
probs_b_cur
),
copy
.
deepcopy
(
probs_b
_prev
,
probs_nb_prev
=
copy
.
deepcopy
(
probs_b_cur
),
copy
.
deepcopy
(
probs_nb_cur
)
## store top beam_size prefixes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录