Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
3adb20b4
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看板
提交
3adb20b4
编写于
9月 26, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eliminate shape and slice
上级
46088c0a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
11 addition
and
10 deletion
+11
-10
paddlespeech/s2t/modules/conformer_convolution.py
paddlespeech/s2t/modules/conformer_convolution.py
+3
-3
paddlespeech/s2t/modules/decoder.py
paddlespeech/s2t/modules/decoder.py
+1
-1
paddlespeech/s2t/modules/encoder.py
paddlespeech/s2t/modules/encoder.py
+1
-1
paddlespeech/s2t/modules/loss.py
paddlespeech/s2t/modules/loss.py
+2
-2
paddlespeech/s2t/modules/subsampling.py
paddlespeech/s2t/modules/subsampling.py
+4
-3
未找到文件。
paddlespeech/s2t/modules/conformer_convolution.py
浏览文件 @
3adb20b4
...
@@ -127,11 +127,11 @@ class ConvolutionModule(nn.Layer):
...
@@ -127,11 +127,11 @@ class ConvolutionModule(nn.Layer):
x
=
x
.
transpose
([
0
,
2
,
1
])
# [B, C, T]
x
=
x
.
transpose
([
0
,
2
,
1
])
# [B, C, T]
# mask batch padding
# mask batch padding
if
paddle
.
shape
(
mask_pad
)
[
2
]
>
0
:
# time > 0
if
mask_pad
.
shape
[
2
]
>
0
:
# time > 0
x
=
x
.
masked_fill
(
mask_pad
,
0.0
)
x
=
x
.
masked_fill
(
mask_pad
,
0.0
)
if
self
.
lorder
>
0
:
if
self
.
lorder
>
0
:
if
paddle
.
shape
(
cache
)
[
2
]
==
0
:
# cache_t == 0
if
cache
.
shape
[
2
]
==
0
:
# cache_t == 0
x
=
nn
.
functional
.
pad
(
x
=
nn
.
functional
.
pad
(
x
,
[
self
.
lorder
,
0
],
'constant'
,
0.0
,
data_format
=
'NCL'
)
x
,
[
self
.
lorder
,
0
],
'constant'
,
0.0
,
data_format
=
'NCL'
)
else
:
else
:
...
@@ -161,7 +161,7 @@ class ConvolutionModule(nn.Layer):
...
@@ -161,7 +161,7 @@ class ConvolutionModule(nn.Layer):
x
=
self
.
pointwise_conv2
(
x
)
x
=
self
.
pointwise_conv2
(
x
)
# mask batch padding
# mask batch padding
if
paddle
.
shape
(
mask_pad
)
[
2
]
>
0
:
# time > 0
if
mask_pad
.
shape
[
2
]
>
0
:
# time > 0
x
=
x
.
masked_fill
(
mask_pad
,
0.0
)
x
=
x
.
masked_fill
(
mask_pad
,
0.0
)
x
=
x
.
transpose
([
0
,
2
,
1
])
# [B, T, C]
x
=
x
.
transpose
([
0
,
2
,
1
])
# [B, T, C]
...
...
paddlespeech/s2t/modules/decoder.py
浏览文件 @
3adb20b4
...
@@ -243,7 +243,7 @@ class TransformerDecoder(BatchScorerInterface, nn.Layer):
...
@@ -243,7 +243,7 @@ class TransformerDecoder(BatchScorerInterface, nn.Layer):
]
]
# batch decoding
# batch decoding
ys_mask
=
subsequent_mask
(
paddle
.
shape
(
ys
)
[
-
1
]).
unsqueeze
(
0
)
# (B,L,L)
ys_mask
=
subsequent_mask
(
ys
.
shape
[
-
1
]).
unsqueeze
(
0
)
# (B,L,L)
xs_mask
=
make_xs_mask
(
xs
).
unsqueeze
(
1
)
# (B,1,T)
xs_mask
=
make_xs_mask
(
xs
).
unsqueeze
(
1
)
# (B,1,T)
logp
,
states
=
self
.
forward_one_step
(
logp
,
states
=
self
.
forward_one_step
(
xs
,
xs_mask
,
ys
,
ys_mask
,
cache
=
batch_state
)
xs
,
xs_mask
,
ys
,
ys_mask
,
cache
=
batch_state
)
...
...
paddlespeech/s2t/modules/encoder.py
浏览文件 @
3adb20b4
...
@@ -246,7 +246,7 @@ class BaseEncoder(nn.Layer):
...
@@ -246,7 +246,7 @@ class BaseEncoder(nn.Layer):
# tensor zeros([0,0,0,0]) support [i:i+1] slice, will return zeros([0,0,0,0]) tensor
# tensor zeros([0,0,0,0]) support [i:i+1] slice, will return zeros([0,0,0,0]) tensor
# raw code as below:
# raw code as below:
# att_cache=att_cache[i:i+1] if elayers > 0 else att_cache,
# att_cache=att_cache[i:i+1] if elayers > 0 else att_cache,
# cnn_cache=cnn_cache[i:i+1] if
paddle.shape(cnn_cache)
[0] > 0 else cnn_cache,
# cnn_cache=cnn_cache[i:i+1] if
cnn_cache.shape
[0] > 0 else cnn_cache,
xs
,
_
,
new_att_cache
,
new_cnn_cache
=
layer
(
xs
,
_
,
new_att_cache
,
new_cnn_cache
=
layer
(
xs
,
xs
,
att_mask
,
att_mask
,
...
...
paddlespeech/s2t/modules/loss.py
浏览文件 @
3adb20b4
...
@@ -85,7 +85,7 @@ class CTCLoss(nn.Layer):
...
@@ -85,7 +85,7 @@ class CTCLoss(nn.Layer):
Returns:
Returns:
[paddle.Tensor]: scalar. If reduction is 'none', then (N), where N =
\t
ext{batch size}.
[paddle.Tensor]: scalar. If reduction is 'none', then (N), where N =
\t
ext{batch size}.
"""
"""
B
=
paddle
.
shape
(
logits
)
[
0
]
B
=
logits
.
shape
[
0
]
# warp-ctc need logits, and do softmax on logits by itself
# warp-ctc need logits, and do softmax on logits by itself
# warp-ctc need activation with shape [T, B, V + 1]
# warp-ctc need activation with shape [T, B, V + 1]
# logits: (B, L, D) -> (L, B, D)
# logits: (B, L, D) -> (L, B, D)
...
@@ -158,7 +158,7 @@ class LabelSmoothingLoss(nn.Layer):
...
@@ -158,7 +158,7 @@ class LabelSmoothingLoss(nn.Layer):
Returns:
Returns:
loss (paddle.Tensor) : The KL loss, scalar float value
loss (paddle.Tensor) : The KL loss, scalar float value
"""
"""
B
,
T
,
D
=
paddle
.
shape
(
x
)
B
,
T
,
D
=
x
.
shape
assert
D
==
self
.
size
assert
D
==
self
.
size
x
=
x
.
reshape
((
-
1
,
self
.
size
))
x
=
x
.
reshape
((
-
1
,
self
.
size
))
target
=
target
.
reshape
([
-
1
])
target
=
target
.
reshape
([
-
1
])
...
...
paddlespeech/s2t/modules/subsampling.py
浏览文件 @
3adb20b4
...
@@ -192,8 +192,8 @@ class Conv2dSubsampling6(Conv2dSubsampling):
...
@@ -192,8 +192,8 @@ class Conv2dSubsampling6(Conv2dSubsampling):
"""
"""
x
=
x
.
unsqueeze
(
1
)
# (b, c, t, f)
x
=
x
.
unsqueeze
(
1
)
# (b, c, 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
.
linear
(
x
.
transpose
([
0
,
2
,
1
,
3
]).
reshape
([
b
,
t
,
c
*
f
]))
x
=
self
.
linear
(
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
][:,
:,
:
-
4
:
3
]
return
x
,
pos_emb
,
x_mask
[:,
:,
:
-
2
:
2
][:,
:,
:
-
4
:
3
]
...
@@ -245,6 +245,7 @@ class Conv2dSubsampling8(Conv2dSubsampling):
...
@@ -245,6 +245,7 @@ class Conv2dSubsampling8(Conv2dSubsampling):
"""
"""
x
=
x
.
unsqueeze
(
1
)
# (b, c, t, f)
x
=
x
.
unsqueeze
(
1
)
# (b, c, t, f)
x
=
self
.
conv
(
x
)
x
=
self
.
conv
(
x
)
x
=
self
.
linear
(
x
.
transpose
([
0
,
2
,
1
,
3
]).
reshape
([
b
,
t
,
c
*
f
]))
b
,
c
,
t
,
f
=
x
.
shape
x
=
self
.
linear
(
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
][:,
:,
:
-
2
:
2
]
return
x
,
pos_emb
,
x_mask
[:,
:,
:
-
2
:
2
][:,
:,
:
-
2
:
2
][:,
:,
:
-
2
:
2
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录