Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
11841096
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看板
未验证
提交
11841096
编写于
2月 08, 2018
作者:
Z
zhxfl
提交者:
GitHub
2月 08, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #642 from zhxfl/fix-627
Fix 627
上级
b62b05fc
6e6ed6b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
13 deletion
+80
-13
fluid/DeepASR/data_utils/augmentor/tests/__init__.py
fluid/DeepASR/data_utils/augmentor/tests/__init__.py
+7
-0
fluid/DeepASR/data_utils/data_reader.py
fluid/DeepASR/data_utils/data_reader.py
+72
-12
fluid/DeepASR/model_utils/__init__.py
fluid/DeepASR/model_utils/__init__.py
+0
-0
fluid/DeepASR/train.py
fluid/DeepASR/train.py
+1
-1
未找到文件。
fluid/DeepASR/data_utils/augmentor/tests/__init__.py
0 → 100644
浏览文件 @
11841096
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
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
fluid/DeepASR/data_utils/data_reader.py
浏览文件 @
11841096
...
...
@@ -62,10 +62,22 @@ class SampleInfoBucket(object):
label_bin_paths (list|tuple): Files containing the binary label data.
label_desc_paths (list|tuple): Files containing the description of
samples' label data.
split_perturb(int): Maximum perturbation value for length of
sub-sentence when splitting long sentence.
split_sentence_threshold(int): Sentence whose length larger than
the value will trigger split operation.
split_sub_sentence_len(int): sub-sentence length is equal to
(split_sub_sentence_len + rand() % split_perturb).
"""
def
__init__
(
self
,
feature_bin_paths
,
feature_desc_paths
,
label_bin_paths
,
label_desc_paths
):
def
__init__
(
self
,
feature_bin_paths
,
feature_desc_paths
,
label_bin_paths
,
label_desc_paths
,
split_perturb
=
50
,
split_sentence_threshold
=
512
,
split_sub_sentence_len
=
256
):
block_num
=
len
(
label_bin_paths
)
assert
len
(
label_desc_paths
)
==
block_num
assert
len
(
feature_bin_paths
)
==
block_num
...
...
@@ -76,6 +88,10 @@ class SampleInfoBucket(object):
self
.
_feature_desc_paths
=
feature_desc_paths
self
.
_label_bin_paths
=
label_bin_paths
self
.
_label_desc_paths
=
label_desc_paths
self
.
_split_perturb
=
split_perturb
self
.
_split_sentence_threshold
=
split_sentence_threshold
self
.
_split_sub_sentence_len
=
split_sub_sentence_len
self
.
_rng
=
random
.
Random
(
0
)
def
generate_sample_info_list
(
self
):
sample_info_list
=
[]
...
...
@@ -102,12 +118,45 @@ class SampleInfoBucket(object):
label_start
=
int
(
label_desc_split
[
2
])
label_size
=
int
(
label_desc_split
[
3
])
label_frame_num
=
int
(
label_desc_split
[
4
])
sample_info_list
.
append
(
SampleInfo
(
feature_bin_path
,
feature_start
,
feature_size
,
feature_frame_num
,
feature_dim
,
label_bin_path
,
label_start
,
label_size
,
label_frame_num
))
assert
feature_frame_num
==
label_frame_num
if
self
.
_split_sentence_threshold
==
-
1
or
\
self
.
_split_perturb
==
-
1
or
\
self
.
_split_sub_sentence_len
==
-
1
\
or
self
.
_split_sentence_threshold
>=
feature_frame_num
:
sample_info_list
.
append
(
SampleInfo
(
feature_bin_path
,
feature_start
,
feature_size
,
feature_frame_num
,
feature_dim
,
label_bin_path
,
label_start
,
label_size
,
label_frame_num
))
#split sentence
else
:
cur_frame_pos
=
0
cur_frame_len
=
0
remain_frame_num
=
feature_frame_num
while
True
:
if
remain_frame_num
>
self
.
_split_sentence_threshold
:
cur_frame_len
=
self
.
_split_sub_sentence_len
+
\
self
.
_rng
.
randint
(
0
,
self
.
_split_perturb
)
if
cur_frame_len
>
remain_frame_num
:
cur_frame_len
=
remain_frame_num
else
:
cur_frame_len
=
remain_frame_num
sample_info_list
.
append
(
SampleInfo
(
feature_bin_path
,
feature_start
+
cur_frame_pos
*
feature_dim
*
4
,
cur_frame_len
*
feature_dim
*
4
,
cur_frame_len
,
feature_dim
,
label_bin_path
,
label_start
+
cur_frame_pos
*
4
,
cur_frame_len
*
4
,
cur_frame_len
))
remain_frame_num
-=
cur_frame_len
cur_frame_pos
+=
cur_frame_len
if
remain_frame_num
<=
0
:
break
print
(
"generate_sample_info_list size "
,
len
(
sample_info_list
))
return
sample_info_list
...
...
@@ -125,7 +174,7 @@ class DataReader(object):
label_file_list (str): File containing paths of label data file and
corresponding description file.
drop_frame_len (int): Samples whose label length above the value will be
dropped.
dropped.
(Using '-1' to disable the policy)
process_num (int): Number of processes for processing data.
sample_buffer_size (int): Buffer size to indicate the maximum samples
cached.
...
...
@@ -149,7 +198,7 @@ class DataReader(object):
sample_buffer_size
=
1024
,
sample_info_buffer_size
=
1024
,
batch_buffer_size
=
1024
,
shuffle_block_num
=
1
,
shuffle_block_num
=
1
0
,
random_seed
=
0
,
verbose
=
0
):
self
.
_feature_file_list
=
feature_file_list
...
...
@@ -253,11 +302,21 @@ class DataReader(object):
sample_info
.
feature_start
,
sample_info
.
feature_size
)
assert
sample_info
.
feature_frame_num
*
sample_info
.
feature_dim
*
4
\
==
len
(
feature_bytes
),
\
(
sample_info
.
feature_bin_path
,
sample_info
.
feature_frame_num
,
sample_info
.
feature_dim
,
len
(
feature_bytes
))
label_bytes
=
read_bytes
(
sample_info
.
label_bin_path
,
sample_info
.
label_start
,
sample_info
.
label_size
)
assert
sample_info
.
label_frame_num
*
4
==
len
(
label_bytes
)
assert
sample_info
.
label_frame_num
*
4
==
len
(
label_bytes
),
(
sample_info
.
label_bin_path
,
sample_info
.
label_array
,
len
(
label_bytes
))
label_array
=
struct
.
unpack
(
'I'
*
sample_info
.
label_frame_num
,
label_bytes
)
label_data
=
np
.
array
(
...
...
@@ -282,7 +341,8 @@ class DataReader(object):
time
.
sleep
(
0.001
)
# drop long sentence
if
self
.
_drop_frame_len
>=
sample_data
[
0
].
shape
[
0
]:
if
self
.
_drop_frame_len
==
-
1
or
\
self
.
_drop_frame_len
>=
sample_data
[
0
].
shape
[
0
]:
sample_queue
.
put
(
sample_data
)
out_order
[
0
]
+=
1
...
...
fluid/DeepASR/model_utils/__init__.py
0 → 100644
浏览文件 @
11841096
fluid/DeepASR/train.py
浏览文件 @
11841096
...
...
@@ -176,7 +176,7 @@ def train(args):
# train data reader
train_data_reader
=
reader
.
DataReader
(
args
.
train_feature_lst
,
args
.
train_label_lst
)
args
.
train_label_lst
,
-
1
)
train_data_reader
.
set_transformers
(
ltrans
)
# train
for
pass_id
in
xrange
(
args
.
pass_num
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录