Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
36e3fcd5
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看板
未验证
提交
36e3fcd5
编写于
5月 28, 2018
作者:
Y
Yibing Liu
提交者:
GitHub
5月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #938 from zhxfl/new_config
New config
上级
075fbcbb
4e600867
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
86 addition
and
23 deletion
+86
-23
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/infer_by_ckpt.py
fluid/DeepASR/infer_by_ckpt.py
+3
-2
fluid/DeepASR/model_utils/model.py
fluid/DeepASR/model_utils/model.py
+15
-15
fluid/DeepASR/tools/profile.py
fluid/DeepASR/tools/profile.py
+4
-3
fluid/DeepASR/train.py
fluid/DeepASR/train.py
+7
-3
未找到文件。
fluid/DeepASR/data_utils/augmentor/tests/test_data_trans.py
浏览文件 @
36e3fcd5
...
...
@@ -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
浏览文件 @
36e3fcd5
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/infer_by_ckpt.py
浏览文件 @
36e3fcd5
...
...
@@ -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
decoder.post_decode_faster
import
Decoder
from
data_utils.util
import
lodtensor_to_ndarray
...
...
@@ -36,7 +37,7 @@ def parse_args():
parser
.
add_argument
(
'--frame_dim'
,
type
=
int
,
default
=
120
*
11
,
default
=
80
,
help
=
'Frame dimension of feature data. (default: %(default)d)'
)
parser
.
add_argument
(
'--stacked_num'
,
...
...
@@ -179,7 +180,7 @@ def infer_from_ckpt(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
()
...
...
fluid/DeepASR/model_utils/model.py
浏览文件 @
36e3fcd5
...
...
@@ -32,25 +32,23 @@ def stacked_lstmp_model(frame_dim,
# network configuration
def
_net_conf
(
feature
,
label
):
seq_conv1
=
fluid
.
layers
.
sequence_conv
(
conv1
=
fluid
.
layers
.
conv2d
(
input
=
feature
,
num_filters
=
1024
,
num_filters
=
32
,
filter_size
=
3
,
filter_stride
=
1
,
bias_attr
=
True
)
bn1
=
fluid
.
layers
.
batch_norm
(
input
=
seq_conv1
,
act
=
"sigmoid"
,
is_test
=
not
is_train
,
momentum
=
0.9
,
epsilon
=
1e-05
,
data_layout
=
'NCHW'
)
stride
=
1
,
padding
=
1
,
bias_attr
=
True
,
act
=
"relu"
)
stack_input
=
bn1
pool1
=
fluid
.
layers
.
pool2d
(
conv1
,
pool_size
=
3
,
pool_type
=
"max"
,
pool_stride
=
2
,
pool_padding
=
0
)
stack_input
=
pool1
for
i
in
range
(
stacked_num
):
fc
=
fluid
.
layers
.
fc
(
input
=
stack_input
,
size
=
hidden_dim
*
4
,
bias_attr
=
Tru
e
)
bias_attr
=
Non
e
)
proj
,
cell
=
fluid
.
layers
.
dynamic_lstmp
(
input
=
fc
,
size
=
hidden_dim
*
4
,
...
...
@@ -62,7 +60,6 @@ def stacked_lstmp_model(frame_dim,
proj_activation
=
"tanh"
)
bn
=
fluid
.
layers
.
batch_norm
(
input
=
proj
,
act
=
"sigmoid"
,
is_test
=
not
is_train
,
momentum
=
0.9
,
epsilon
=
1e-05
,
...
...
@@ -80,7 +77,10 @@ def stacked_lstmp_model(frame_dim,
# data feeder
feature
=
fluid
.
layers
.
data
(
name
=
"feature"
,
shape
=
[
-
1
,
frame_dim
],
dtype
=
"float32"
,
lod_level
=
1
)
name
=
"feature"
,
shape
=
[
-
1
,
3
,
11
,
frame_dim
],
dtype
=
"float32"
,
lod_level
=
1
)
label
=
fluid
.
layers
.
data
(
name
=
"label"
,
shape
=
[
-
1
,
1
],
dtype
=
"int64"
,
lod_level
=
1
)
...
...
fluid/DeepASR/tools/profile.py
浏览文件 @
36e3fcd5
...
...
@@ -13,6 +13,7 @@ import _init_paths
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
model_utils.model
import
stacked_lstmp_model
from
data_utils.util
import
lodtensor_to_ndarray
...
...
@@ -87,7 +88,7 @@ def parse_args():
parser
.
add_argument
(
'--max_batch_num'
,
type
=
int
,
default
=
1
0
,
default
=
1
1
,
help
=
'Maximum number of batches for profiling. (default: %(default)d)'
)
parser
.
add_argument
(
'--first_batches_to_skip'
,
...
...
@@ -146,10 +147,10 @@ def profile(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
)
]
data_reader
=
reader
.
AsyncDataReader
(
args
.
feature_lst
,
args
.
label_lst
)
data_reader
=
reader
.
AsyncDataReader
(
args
.
feature_lst
,
args
.
label_lst
,
-
1
)
data_reader
.
set_transformers
(
ltrans
)
feature_t
=
fluid
.
LoDTensor
()
...
...
fluid/DeepASR/train.py
浏览文件 @
36e3fcd5
...
...
@@ -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
...
...
@@ -33,7 +34,7 @@ def parse_args():
parser
.
add_argument
(
'--frame_dim'
,
type
=
int
,
default
=
120
*
11
,
default
=
80
,
help
=
'Frame dimension of feature data. (default: %(default)d)'
)
parser
.
add_argument
(
'--stacked_num'
,
...
...
@@ -53,7 +54,7 @@ def parse_args():
parser
.
add_argument
(
'--class_num'
,
type
=
int
,
default
=
1749
,
default
=
3040
,
help
=
'Number of classes in label. (default: %(default)d)'
)
parser
.
add_argument
(
'--pass_num'
,
...
...
@@ -157,6 +158,7 @@ def train(args):
# program for test
test_program
=
fluid
.
default_main_program
().
clone
()
#optimizer = fluid.optimizer.Momentum(learning_rate=args.learning_rate, momentum=0.9)
optimizer
=
fluid
.
optimizer
.
Adam
(
learning_rate
=
args
.
learning_rate
)
optimizer
.
minimize
(
avg_cost
)
...
...
@@ -171,7 +173,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
(
5
,
5
),
trans_delay
.
TransDelay
(
5
)
]
feature_t
=
fluid
.
LoDTensor
()
...
...
@@ -220,6 +222,8 @@ def train(args):
args
.
minimum_batch_size
)):
# load_data
(
features
,
labels
,
lod
,
name_lst
)
=
batch_data
features
=
np
.
reshape
(
features
,
(
-
1
,
11
,
3
,
args
.
frame_dim
))
features
=
np
.
transpose
(
features
,
(
0
,
2
,
1
,
3
))
feature_t
.
set
(
features
,
place
)
feature_t
.
set_lod
([
lod
])
label_t
.
set
(
labels
,
place
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录