Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
4b5410ee
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
1 年多 前同步成功
通知
207
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看板
提交
4b5410ee
编写于
8月 16, 2021
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove fixed hack api
上级
86e42f3d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
2 addition
and
50 deletion
+2
-50
deepspeech/__init__.py
deepspeech/__init__.py
+0
-49
deepspeech/modules/loss.py
deepspeech/modules/loss.py
+2
-1
未找到文件。
deepspeech/__init__.py
浏览文件 @
4b5410ee
...
...
@@ -30,24 +30,13 @@ logger = Log(__name__).getlog()
logger
.
warn
=
logger
.
warning
########### hcak paddle #############
paddle
.
bool
=
'bool'
paddle
.
float16
=
'float16'
paddle
.
half
=
'float16'
paddle
.
float32
=
'float32'
paddle
.
float
=
'float32'
paddle
.
float64
=
'float64'
paddle
.
double
=
'float64'
paddle
.
int8
=
'int8'
paddle
.
int16
=
'int16'
paddle
.
short
=
'int16'
paddle
.
int32
=
'int32'
paddle
.
int
=
'int32'
paddle
.
int64
=
'int64'
paddle
.
long
=
'int64'
paddle
.
uint8
=
'uint8'
paddle
.
uint16
=
'uint16'
paddle
.
complex64
=
'complex64'
paddle
.
complex128
=
'complex128'
paddle
.
cdouble
=
'complex128'
...
...
@@ -403,45 +392,7 @@ if not hasattr(paddle.nn.functional, 'glu'):
# return x * 0.5 * (1.0 + paddle.erf(x / math.sqrt(2.0)))
# hack loss
def
ctc_loss
(
logits
,
labels
,
input_lengths
,
label_lengths
,
blank
=
0
,
reduction
=
'mean'
,
norm_by_times
=
True
):
#logger.info("my ctc loss with norm by times")
## https://github.com/PaddlePaddle/Paddle/blob/f5ca2db2cc/paddle/fluid/operators/warpctc_op.h#L403
loss_out
=
paddle
.
fluid
.
layers
.
warpctc
(
logits
,
labels
,
blank
,
norm_by_times
,
input_lengths
,
label_lengths
)
loss_out
=
paddle
.
fluid
.
layers
.
squeeze
(
loss_out
,
[
-
1
])
assert
reduction
in
[
'mean'
,
'sum'
,
'none'
]
if
reduction
==
'mean'
:
loss_out
=
paddle
.
mean
(
loss_out
/
label_lengths
)
elif
reduction
==
'sum'
:
loss_out
=
paddle
.
sum
(
loss_out
)
return
loss_out
logger
.
warn
(
"override ctc_loss of paddle.nn.functional if exists, remove this when fixed!"
)
F
.
ctc_loss
=
ctc_loss
########### hcak paddle.nn #############
if
not
hasattr
(
paddle
.
nn
,
'Module'
):
logger
.
warn
(
"register user Module to paddle.nn, remove this when fixed!"
)
setattr
(
paddle
.
nn
,
'Module'
,
paddle
.
nn
.
Layer
)
# maybe cause assert isinstance(sublayer, core.Layer)
if
not
hasattr
(
paddle
.
nn
,
'ModuleList'
):
logger
.
warn
(
"register user ModuleList to paddle.nn, remove this when fixed!"
)
setattr
(
paddle
.
nn
,
'ModuleList'
,
paddle
.
nn
.
LayerList
)
class
GLU
(
nn
.
Layer
):
"""Gated Linear Units (GLU) Layer"""
...
...
deepspeech/modules/loss.py
浏览文件 @
4b5410ee
...
...
@@ -48,7 +48,8 @@ class CTCLoss(nn.Layer):
logits
=
logits
.
transpose
([
1
,
0
,
2
])
# (TODO:Hui Zhang) ctc loss does not support int64 labels
ys_pad
=
ys_pad
.
astype
(
paddle
.
int32
)
loss
=
self
.
loss
(
logits
,
ys_pad
,
hlens
,
ys_lens
)
loss
=
self
.
loss
(
logits
,
ys_pad
,
hlens
,
ys_lens
,
norm_by_times
=
self
.
batch_average
)
if
self
.
batch_average
:
# Batch-size average
loss
=
loss
/
B
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录