Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
b7388ce2
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看板
提交
b7388ce2
编写于
9月 22, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eliminate useless unsqueese
上级
7382050e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
6 addition
and
7 deletion
+6
-7
paddlespeech/s2t/modules/embedding.py
paddlespeech/s2t/modules/embedding.py
+3
-4
paddlespeech/s2t/modules/encoder.py
paddlespeech/s2t/modules/encoder.py
+3
-3
未找到文件。
paddlespeech/s2t/modules/embedding.py
浏览文件 @
b7388ce2
...
@@ -89,7 +89,7 @@ class PositionalEncoding(nn.Layer, PositionalEncodingInterface):
...
@@ -89,7 +89,7 @@ class PositionalEncoding(nn.Layer, PositionalEncodingInterface):
self
.
max_len
=
max_len
self
.
max_len
=
max_len
self
.
xscale
=
paddle
.
to_tensor
(
math
.
sqrt
(
self
.
d_model
))
self
.
xscale
=
paddle
.
to_tensor
(
math
.
sqrt
(
self
.
d_model
))
self
.
dropout
=
nn
.
Dropout
(
p
=
dropout_rate
)
self
.
dropout
=
nn
.
Dropout
(
p
=
dropout_rate
)
self
.
pe
=
paddle
.
zeros
([
self
.
max_len
,
self
.
d_model
])
#[
T,D]
self
.
pe
=
paddle
.
zeros
([
1
,
self
.
max_len
,
self
.
d_model
])
#[B=1,
T,D]
position
=
paddle
.
arange
(
position
=
paddle
.
arange
(
0
,
self
.
max_len
,
dtype
=
paddle
.
float32
).
unsqueeze
(
1
)
#[T, 1]
0
,
self
.
max_len
,
dtype
=
paddle
.
float32
).
unsqueeze
(
1
)
#[T, 1]
...
@@ -97,9 +97,8 @@ class PositionalEncoding(nn.Layer, PositionalEncodingInterface):
...
@@ -97,9 +97,8 @@ class PositionalEncoding(nn.Layer, PositionalEncodingInterface):
paddle
.
arange
(
0
,
self
.
d_model
,
2
,
dtype
=
paddle
.
float32
)
*
paddle
.
arange
(
0
,
self
.
d_model
,
2
,
dtype
=
paddle
.
float32
)
*
-
(
math
.
log
(
10000.0
)
/
self
.
d_model
))
-
(
math
.
log
(
10000.0
)
/
self
.
d_model
))
self
.
pe
[:,
0
::
2
]
=
paddle
.
sin
(
position
*
div_term
)
self
.
pe
[:,
:,
0
::
2
]
=
paddle
.
sin
(
position
*
div_term
)
self
.
pe
[:,
1
::
2
]
=
paddle
.
cos
(
position
*
div_term
)
self
.
pe
[:,
:,
1
::
2
]
=
paddle
.
cos
(
position
*
div_term
)
self
.
pe
=
self
.
pe
.
unsqueeze
(
0
)
#[1, T, D]
def
forward
(
self
,
x
:
paddle
.
Tensor
,
def
forward
(
self
,
x
:
paddle
.
Tensor
,
offset
:
int
=
0
)
->
Tuple
[
paddle
.
Tensor
,
paddle
.
Tensor
]:
offset
:
int
=
0
)
->
Tuple
[
paddle
.
Tensor
,
paddle
.
Tensor
]:
...
...
paddlespeech/s2t/modules/encoder.py
浏览文件 @
b7388ce2
...
@@ -264,15 +264,15 @@ class BaseEncoder(nn.Layer):
...
@@ -264,15 +264,15 @@ class BaseEncoder(nn.Layer):
# new_att_cache = (1, head, attention_key_size, d_k*2)
# new_att_cache = (1, head, attention_key_size, d_k*2)
# new_cnn_cache = (B=1, hidden-dim, cache_t2)
# new_cnn_cache = (B=1, hidden-dim, cache_t2)
r_att_cache
.
append
(
new_att_cache
[:,
:,
next_cache_start
:,
:])
r_att_cache
.
append
(
new_att_cache
[:,
:,
next_cache_start
:,
:])
r_cnn_cache
.
append
(
new_cnn_cache
.
unsqueeze
(
0
)
)
# add elayer dim
r_cnn_cache
.
append
(
new_cnn_cache
)
# add elayer dim
if
self
.
normalize_before
:
if
self
.
normalize_before
:
xs
=
self
.
after_norm
(
xs
)
xs
=
self
.
after_norm
(
xs
)
# r_att_cache (elayers, head, T, d_k*2)
# r_att_cache (elayers, head, T, d_k*2)
# r_cnn_cache
(
elayers, B=1, hidden-dim, cache_t2)
# r_cnn_cache
(
elayers, B=1, hidden-dim, cache_t2)
r_att_cache
=
paddle
.
concat
(
r_att_cache
,
axis
=
0
)
r_att_cache
=
paddle
.
concat
(
r_att_cache
,
axis
=
0
)
r_cnn_cache
=
paddle
.
concat
(
r_cnn_cache
,
axis
=
0
)
r_cnn_cache
=
paddle
.
stack
(
r_cnn_cache
,
axis
=
0
)
return
xs
,
r_att_cache
,
r_cnn_cache
return
xs
,
r_att_cache
,
r_cnn_cache
def
forward_chunk_by_chunk
(
def
forward_chunk_by_chunk
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录