Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
c2c8a662
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看板
提交
c2c8a662
编写于
9月 26, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor reshape
上级
6de81d74
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
3 addition
and
6 deletion
+3
-6
paddlespeech/s2t/modules/embedding.py
paddlespeech/s2t/modules/embedding.py
+1
-4
paddlespeech/s2t/modules/subsampling.py
paddlespeech/s2t/modules/subsampling.py
+2
-2
未找到文件。
paddlespeech/s2t/modules/embedding.py
浏览文件 @
c2c8a662
...
@@ -110,12 +110,10 @@ class PositionalEncoding(nn.Layer, PositionalEncodingInterface):
...
@@ -110,12 +110,10 @@ class PositionalEncoding(nn.Layer, PositionalEncodingInterface):
paddle.Tensor: Encoded tensor. Its shape is (batch, time, ...)
paddle.Tensor: Encoded tensor. Its shape is (batch, time, ...)
paddle.Tensor: for compatibility to RelPositionalEncoding, (batch=1, time, ...)
paddle.Tensor: for compatibility to RelPositionalEncoding, (batch=1, time, ...)
"""
"""
T
=
x
.
shape
[
1
]
assert
offset
+
x
.
shape
[
assert
offset
+
x
.
shape
[
1
]
<
self
.
max_len
,
"offset: {} + x.shape[1]: {} is larger than the max_len: {}"
.
format
(
1
]
<
self
.
max_len
,
"offset: {} + x.shape[1]: {} is larger than the max_len: {}"
.
format
(
offset
,
x
.
shape
[
1
],
self
.
max_len
)
offset
,
x
.
shape
[
1
],
self
.
max_len
)
#TODO(Hui Zhang): using T = paddle.shape(x)[1], __getitem__ not support Tensor
pos_emb
=
self
.
pe
[:,
offset
:
offset
+
x
.
shape
[
1
]]
pos_emb
=
self
.
pe
[:,
offset
:
offset
+
T
]
x
=
x
*
self
.
xscale
+
pos_emb
x
=
x
*
self
.
xscale
+
pos_emb
return
self
.
dropout
(
x
),
self
.
dropout
(
pos_emb
)
return
self
.
dropout
(
x
),
self
.
dropout
(
pos_emb
)
...
@@ -164,6 +162,5 @@ class RelPositionalEncoding(PositionalEncoding):
...
@@ -164,6 +162,5 @@ class RelPositionalEncoding(PositionalEncoding):
1
]
<
self
.
max_len
,
"offset: {} + x.shape[1]: {} is larger than the max_len: {}"
.
format
(
1
]
<
self
.
max_len
,
"offset: {} + x.shape[1]: {} is larger than the max_len: {}"
.
format
(
offset
,
x
.
shape
[
1
],
self
.
max_len
)
offset
,
x
.
shape
[
1
],
self
.
max_len
)
x
=
x
*
self
.
xscale
x
=
x
*
self
.
xscale
#TODO(Hui Zhang): using paddle.shape(x)[1], __getitem__ not support Tensor
pos_emb
=
self
.
pe
[:,
offset
:
offset
+
x
.
shape
[
1
]]
pos_emb
=
self
.
pe
[:,
offset
:
offset
+
x
.
shape
[
1
]]
return
self
.
dropout
(
x
),
self
.
dropout
(
pos_emb
)
return
self
.
dropout
(
x
),
self
.
dropout
(
pos_emb
)
paddlespeech/s2t/modules/subsampling.py
浏览文件 @
c2c8a662
...
@@ -139,8 +139,8 @@ class Conv2dSubsampling4(Conv2dSubsampling):
...
@@ -139,8 +139,8 @@ class Conv2dSubsampling4(Conv2dSubsampling):
"""
"""
x
=
x
.
unsqueeze
(
1
)
# (b, c=1, t, f)
x
=
x
.
unsqueeze
(
1
)
# (b, c=1, t, f)
x
=
self
.
conv
(
x
)
x
=
self
.
conv
(
x
)
b
,
c
,
t
,
f
=
paddle
.
shape
(
x
)
b
,
c
,
t
,
f
=
x
.
shape
x
=
self
.
out
(
x
.
transpose
([
0
,
2
,
1
,
3
]).
reshape
([
b
,
t
,
c
*
f
]))
x
=
self
.
out
(
x
.
transpose
([
0
,
2
,
1
,
3
]).
reshape
([
b
,
-
1
,
c
*
f
]))
x
,
pos_emb
=
self
.
pos_enc
(
x
,
offset
)
x
,
pos_emb
=
self
.
pos_enc
(
x
,
offset
)
return
x
,
pos_emb
,
x_mask
[:,
:,
:
-
2
:
2
][:,
:,
:
-
2
:
2
]
return
x
,
pos_emb
,
x_mask
[:,
:,
:
-
2
:
2
][:,
:,
:
-
2
:
2
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录