Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
94918305
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看板
提交
94918305
编写于
7月 02, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
type_as to astype
上级
82b8296f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
4 addition
and
5 deletion
+4
-5
deepspeech/modules/conv.py
deepspeech/modules/conv.py
+0
-1
deepspeech/modules/encoder.py
deepspeech/modules/encoder.py
+1
-1
deepspeech/modules/loss.py
deepspeech/modules/loss.py
+1
-1
deepspeech/utils/tensor_utils.py
deepspeech/utils/tensor_utils.py
+2
-2
未找到文件。
deepspeech/modules/conv.py
浏览文件 @
94918305
...
...
@@ -114,7 +114,6 @@ class ConvBn(nn.Layer):
masks
=
make_non_pad_mask
(
x_len
)
#[B, T]
masks
=
masks
.
unsqueeze
(
1
).
unsqueeze
(
1
)
# [B, 1, 1, T]
# TODO(Hui Zhang): not support bool multiply
# masks = masks.type_as(x)
masks
=
masks
.
astype
(
x
.
dtype
)
x
=
x
.
multiply
(
masks
)
...
...
deepspeech/modules/encoder.py
浏览文件 @
94918305
...
...
@@ -159,7 +159,7 @@ class BaseEncoder(nn.Layer):
if
self
.
global_cmvn
is
not
None
:
xs
=
self
.
global_cmvn
(
xs
)
#TODO(Hui Zhang): self.embed(xs, masks, offset=0), stride_slice not support bool tensor
xs
,
pos_emb
,
masks
=
self
.
embed
(
xs
,
masks
.
type_as
(
xs
),
offset
=
0
)
xs
,
pos_emb
,
masks
=
self
.
embed
(
xs
,
masks
.
astype
(
xs
.
dtype
),
offset
=
0
)
#TODO(Hui Zhang): remove mask.astype, stride_slice not support bool tensor
masks
=
masks
.
astype
(
paddle
.
bool
)
#TODO(Hui Zhang): mask_pad = ~masks
...
...
deepspeech/modules/loss.py
浏览文件 @
94918305
...
...
@@ -136,7 +136,7 @@ class LabelSmoothingLoss(nn.Layer):
#TODO(Hui Zhang): sum not support bool type
#total = len(target) - int(ignore.sum())
total
=
len
(
target
)
-
int
(
ignore
.
type_as
(
target
).
sum
())
total
=
len
(
target
)
-
int
(
ignore
.
astype
(
target
.
dtype
).
sum
())
denom
=
total
if
self
.
normalize_length
else
B
#numer = (kl * (1 - ignore)).sum()
numer
=
kl
.
masked_fill
(
ignore
.
unsqueeze
(
1
),
0
).
sum
()
...
...
deepspeech/utils/tensor_utils.py
浏览文件 @
94918305
...
...
@@ -159,8 +159,8 @@ def th_accuracy(pad_outputs: paddle.Tensor,
# pad_pred.masked_select(mask) == pad_targets.masked_select(mask))
numerator
=
(
pad_pred
.
masked_select
(
mask
)
==
pad_targets
.
masked_select
(
mask
))
numerator
=
paddle
.
sum
(
numerator
.
type_as
(
pad_targets
))
numerator
=
paddle
.
sum
(
numerator
.
astype
(
pad_targets
.
dtype
))
#TODO(Hui Zhang): sum not support bool type
# denominator = paddle.sum(mask)
denominator
=
paddle
.
sum
(
mask
.
type_as
(
pad_targets
))
denominator
=
paddle
.
sum
(
mask
.
astype
(
pad_targets
.
dtype
))
return
float
(
numerator
)
/
float
(
denominator
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录