Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
77e8940c
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看板
提交
77e8940c
编写于
7月 13, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix broadcast_shape
上级
42a5bdf8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
3 addition
and
4 deletion
+3
-4
deepspeech/utils/tensor_utils.py
deepspeech/utils/tensor_utils.py
+3
-4
未找到文件。
deepspeech/utils/tensor_utils.py
浏览文件 @
77e8940c
...
@@ -25,6 +25,7 @@ __all__ = ["masked_fill", "pad_sequence", "add_sos_eos", "th_accuracy"]
...
@@ -25,6 +25,7 @@ __all__ = ["masked_fill", "pad_sequence", "add_sos_eos", "th_accuracy"]
logger
=
Log
(
__name__
).
getlog
()
logger
=
Log
(
__name__
).
getlog
()
@
paddle
.
jit
.
not_to_static
def
is_broadcastable
(
shp1
,
shp2
):
def
is_broadcastable
(
shp1
,
shp2
):
for
a
,
b
in
zip
(
shp1
[::
-
1
],
shp2
[::
-
1
]):
for
a
,
b
in
zip
(
shp1
[::
-
1
],
shp2
[::
-
1
]):
if
a
==
1
or
b
==
1
or
a
==
b
:
if
a
==
1
or
b
==
1
or
a
==
b
:
...
@@ -39,10 +40,8 @@ def masked_fill(xs: paddle.Tensor,
...
@@ -39,10 +40,8 @@ def masked_fill(xs: paddle.Tensor,
value
:
Union
[
float
,
int
]):
value
:
Union
[
float
,
int
]):
if
paddle
.
in_dynamic_mode
():
if
paddle
.
in_dynamic_mode
():
assert
is_broadcastable
(
xs
.
shape
,
mask
.
shape
)
is
True
assert
is_broadcastable
(
xs
.
shape
,
mask
.
shape
)
is
True
bshape
=
paddle
.
broadcast_shape
(
xs
.
shape
,
mask
.
shape
)
# broadcast_shape input should be `list`
else
:
bshape
=
paddle
.
broadcast_shape
(
list
(
xs
.
shape
),
list
(
mask
.
shape
))
# TODO(Hui Zhang): support broadcast_shape in static graph
bshape
=
xs
.
shape
mask
=
mask
.
broadcast_to
(
bshape
)
mask
=
mask
.
broadcast_to
(
bshape
)
trues
=
paddle
.
ones_like
(
xs
)
*
value
trues
=
paddle
.
ones_like
(
xs
)
*
value
xs
=
paddle
.
where
(
mask
,
trues
,
xs
)
xs
=
paddle
.
where
(
mask
,
trues
,
xs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录