Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
5ae580c8
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5ae580c8
编写于
4月 05, 2018
作者:
Z
zhxfl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add trans delay
上级
a4d00a37
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
1 deletion
+59
-1
fluid/DeepASR/data_utils/augmentor/tests/test_data_trans.py
fluid/DeepASR/data_utils/augmentor/tests/test_data_trans.py
+20
-0
fluid/DeepASR/data_utils/augmentor/trans_delay.py
fluid/DeepASR/data_utils/augmentor/trans_delay.py
+37
-0
fluid/DeepASR/train.py
fluid/DeepASR/train.py
+2
-1
未找到文件。
fluid/DeepASR/data_utils/augmentor/tests/test_data_trans.py
浏览文件 @
5ae580c8
...
...
@@ -8,6 +8,7 @@ import numpy as np
import
data_utils.augmentor.trans_mean_variance_norm
as
trans_mean_variance_norm
import
data_utils.augmentor.trans_add_delta
as
trans_add_delta
import
data_utils.augmentor.trans_splice
as
trans_splice
import
data_utils.augmentor.trans_delay
as
trans_delay
class
TestTransMeanVarianceNorm
(
unittest
.
TestCase
):
...
...
@@ -112,5 +113,24 @@ class TestTransSplict(unittest.TestCase):
self
.
assertAlmostEqual
(
feature
[
i
][
j
*
10
+
k
],
cur_val
)
class
TestTransDelay
(
unittest
.
TestCase
):
"""unittest TransDelay
"""
def
test_perform
(
self
):
label
=
np
.
zeros
((
10
,
1
),
dtype
=
"int64"
)
for
i
in
xrange
(
10
):
label
[
i
][
0
]
=
i
trans
=
trans_delay
.
TransDelay
(
5
)
(
_
,
label
,
_
)
=
trans
.
perform_trans
((
None
,
label
,
None
))
for
i
in
xrange
(
5
):
self
.
assertAlmostEqual
(
label
[
i
+
5
][
0
],
i
)
for
i
in
xrange
(
5
):
self
.
assertAlmostEqual
(
label
[
i
][
0
],
0
)
if
__name__
==
'__main__'
:
unittest
.
main
()
fluid/DeepASR/data_utils/augmentor/trans_delay.py
0 → 100644
浏览文件 @
5ae580c8
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
numpy
as
np
import
math
class
TransDelay
(
object
):
""" Delay label, and copy first label value in the front.
Attributes:
_delay_time : the delay frame num of label
"""
def
__init__
(
self
,
delay_time
):
"""init construction
Args:
delay_time : the delay frame num of label
"""
self
.
_delay_time
=
delay_time
def
perform_trans
(
self
,
sample
):
"""
Args:
sample(object):input sample, contain feature numpy and label numpy, sample name list
Returns:
(feature, label, name)
"""
(
feature
,
label
,
name
)
=
sample
shape
=
label
.
shape
assert
len
(
shape
)
==
2
label
[
self
.
_delay_time
:
shape
[
0
]]
=
label
[
0
:
shape
[
0
]
-
self
.
_delay_time
]
for
i
in
xrange
(
self
.
_delay_time
):
label
[
i
][
0
]
=
label
[
self
.
_delay_time
][
0
]
return
(
feature
,
label
,
name
)
fluid/DeepASR/train.py
浏览文件 @
5ae580c8
...
...
@@ -12,6 +12,7 @@ import paddle.fluid as fluid
import
data_utils.augmentor.trans_mean_variance_norm
as
trans_mean_variance_norm
import
data_utils.augmentor.trans_add_delta
as
trans_add_delta
import
data_utils.augmentor.trans_splice
as
trans_splice
import
data_utils.augmentor.trans_delay
as
trans_delay
import
data_utils.async_data_reader
as
reader
from
data_utils.util
import
lodtensor_to_ndarray
from
model_utils.model
import
stacked_lstmp_model
...
...
@@ -171,7 +172,7 @@ def train(args):
ltrans
=
[
trans_add_delta
.
TransAddDelta
(
2
,
2
),
trans_mean_variance_norm
.
TransMeanVarianceNorm
(
args
.
mean_var
),
trans_splice
.
TransSplice
()
trans_splice
.
TransSplice
()
,
trans_delay
.
TransDelay
(
5
)
]
feature_t
=
fluid
.
LoDTensor
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录