Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
4c09927f
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看板
提交
4c09927f
编写于
5月 24, 2022
作者:
H
huangyuxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
e1888f9a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
4 addition
and
4 deletion
+4
-4
paddlespeech/s2t/__init__.py
paddlespeech/s2t/__init__.py
+1
-1
paddlespeech/s2t/models/lm/transformer.py
paddlespeech/s2t/models/lm/transformer.py
+2
-2
paddlespeech/s2t/modules/encoder.py
paddlespeech/s2t/modules/encoder.py
+1
-1
未找到文件。
paddlespeech/s2t/__init__.py
浏览文件 @
4c09927f
...
@@ -200,7 +200,7 @@ if not hasattr(paddle.Tensor, 'view'):
...
@@ -200,7 +200,7 @@ if not hasattr(paddle.Tensor, 'view'):
def
view_as
(
xs
:
paddle
.
Tensor
,
ys
:
paddle
.
Tensor
)
->
paddle
.
Tensor
:
def
view_as
(
xs
:
paddle
.
Tensor
,
ys
:
paddle
.
Tensor
)
->
paddle
.
Tensor
:
return
xs
.
reshape
(
ys
.
s
ize
()
)
return
xs
.
reshape
(
ys
.
s
hape
)
if
not
hasattr
(
paddle
.
Tensor
,
'view_as'
):
if
not
hasattr
(
paddle
.
Tensor
,
'view_as'
):
...
...
paddlespeech/s2t/models/lm/transformer.py
浏览文件 @
4c09927f
...
@@ -90,7 +90,7 @@ class TransformerLM(nn.Layer, LMInterface, BatchScorerInterface):
...
@@ -90,7 +90,7 @@ class TransformerLM(nn.Layer, LMInterface, BatchScorerInterface):
def
_target_mask
(
self
,
ys_in_pad
):
def
_target_mask
(
self
,
ys_in_pad
):
ys_mask
=
ys_in_pad
!=
0
ys_mask
=
ys_in_pad
!=
0
m
=
subsequent_mask
(
ys_mask
.
s
ize
(
-
1
)).
unsqueeze
(
0
)
m
=
subsequent_mask
(
ys_mask
.
s
hape
[
-
1
]
)).
unsqueeze
(
0
)
return
ys_mask
.
unsqueeze
(
-
2
)
&
m
return
ys_mask
.
unsqueeze
(
-
2
)
&
m
def
forward
(
self
,
x
:
paddle
.
Tensor
,
t
:
paddle
.
Tensor
def
forward
(
self
,
x
:
paddle
.
Tensor
,
t
:
paddle
.
Tensor
...
@@ -112,7 +112,7 @@ class TransformerLM(nn.Layer, LMInterface, BatchScorerInterface):
...
@@ -112,7 +112,7 @@ class TransformerLM(nn.Layer, LMInterface, BatchScorerInterface):
in perplexity: p(t)^{-n} = exp(-log p(t) / n)
in perplexity: p(t)^{-n} = exp(-log p(t) / n)
"""
"""
batch_size
=
x
.
s
ize
(
0
)
batch_size
=
x
.
s
hape
[
0
]
xm
=
x
!=
0
xm
=
x
!=
0
xlen
=
xm
.
sum
(
axis
=
1
)
xlen
=
xm
.
sum
(
axis
=
1
)
if
self
.
embed_drop
is
not
None
:
if
self
.
embed_drop
is
not
None
:
...
...
paddlespeech/s2t/modules/encoder.py
浏览文件 @
4c09927f
...
@@ -218,7 +218,7 @@ class BaseEncoder(nn.Layer):
...
@@ -218,7 +218,7 @@ class BaseEncoder(nn.Layer):
assert
xs
.
shape
[
0
]
==
1
# batch size must be one
assert
xs
.
shape
[
0
]
==
1
# batch size must be one
# tmp_masks is just for interface compatibility
# tmp_masks is just for interface compatibility
# TODO(Hui Zhang): stride_slice not support bool tensor
# TODO(Hui Zhang): stride_slice not support bool tensor
# tmp_masks = paddle.ones([1, xs.s
ize(1)
], dtype=paddle.bool)
# tmp_masks = paddle.ones([1, xs.s
hape[1]
], dtype=paddle.bool)
tmp_masks
=
paddle
.
ones
([
1
,
xs
.
shape
[
1
]],
dtype
=
paddle
.
int32
)
tmp_masks
=
paddle
.
ones
([
1
,
xs
.
shape
[
1
]],
dtype
=
paddle
.
int32
)
tmp_masks
=
tmp_masks
.
unsqueeze
(
1
)
#[B=1, C=1, T]
tmp_masks
=
tmp_masks
.
unsqueeze
(
1
)
#[B=1, C=1, T]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录