Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
2112ee1e
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看板
提交
2112ee1e
编写于
7月 05, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix decoder mask
上级
1ff97432
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
9 deletion
+19
-9
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+13
-8
deepspeech/modules/decoder.py
deepspeech/modules/decoder.py
+6
-1
未找到文件。
deepspeech/exps/u2/model.py
浏览文件 @
2112ee1e
...
...
@@ -601,17 +601,22 @@ class U2Tester(U2Trainer):
# assert isinstance(input_spec, list), type(input_spec)
infer_model
.
eval
()
#static_model = paddle.jit.to_static(infer_model., input_spec=input_spec)
decoder_max_time
=
100
encoder_max_time
=
None
encoder_model_size
=
256
static_model
=
paddle
.
jit
.
to_static
(
infer_model
.
forward_attention_decoder
,
infer_model
.
forward_attention_decoder
,
input_spec
=
[
paddle
.
static
.
InputSpec
(
shape
=
[
1
,
None
],
dtype
=
'int32'
),
paddle
.
static
.
InputSpec
(
shape
=
[
1
],
dtype
=
'int32'
),
paddle
.
static
.
InputSpec
(
shape
=
[
1
,
None
,
256
],
dtype
=
'int32'
),
]
)
paddle
.
static
.
InputSpec
(
shape
=
[
1
,
decoder_max_time
],
dtype
=
'int32'
),
# tgt
paddle
.
static
.
InputSpec
(
shape
=
[
1
],
dtype
=
'int32'
),
# tgt_len
paddle
.
static
.
InputSpec
(
shape
=
[
1
,
encoder_max_time
,
encoder_model_size
],
dtype
=
'int32'
),
# encoder_out
])
logger
.
info
(
f
"Export code:
{
static_model
}
"
)
paddle
.
jit
.
save
(
static_model
,
self
.
args
.
export_path
)
def
run_export
(
self
):
...
...
deepspeech/modules/decoder.py
浏览文件 @
2112ee1e
...
...
@@ -120,7 +120,7 @@ class TransformerDecoder(nn.Module):
"""
tgt
=
ys_in_pad
# tgt_mask: (B, 1, L)
tgt_mask
=
(
make_non_pad_mask
(
ys_in_lens
).
unsqueeze
(
1
)
)
tgt_mask
=
make_non_pad_mask
(
ys_in_lens
).
unsqueeze
(
1
)
# m: (1, L, L)
m
=
subsequent_mask
(
tgt_mask
.
shape
[
-
1
]).
unsqueeze
(
0
)
# tgt_mask: (B, L, L)
...
...
@@ -164,19 +164,24 @@ class TransformerDecoder(nn.Module):
y.shape` is (batch, token)
"""
x
,
_
=
self
.
embed
(
tgt
)
new_cache
=
[]
for
i
,
decoder
in
enumerate
(
self
.
decoders
):
if
cache
is
None
:
c
=
None
else
:
c
=
cache
[
i
]
x
,
tgt_mask
,
memory
,
memory_mask
=
decoder
(
x
,
tgt_mask
,
memory
,
memory_mask
,
cache
=
c
)
new_cache
.
append
(
x
)
if
self
.
normalize_before
:
y
=
self
.
after_norm
(
x
[:,
-
1
])
else
:
y
=
x
[:,
-
1
]
if
self
.
use_output_layer
:
y
=
paddle
.
log_softmax
(
self
.
output_layer
(
y
),
axis
=-
1
)
return
y
,
new_cache
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录