Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
91b3ed00
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看板
提交
91b3ed00
编写于
2月 04, 2018
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make some parameters configurable including buffer size and random seed
etc.
上级
b24a2c20
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
11 deletion
+16
-11
fluid/DeepASR/data_utils/parallel_reader.py
fluid/DeepASR/data_utils/parallel_reader.py
+16
-11
未找到文件。
fluid/DeepASR/data_utils/parallel_reader.py
浏览文件 @
91b3ed00
...
...
@@ -3,7 +3,6 @@ from __future__ import division
from
__future__
import
print_function
import
random
import
Queue
import
numpy
as
np
import
struct
import
data_utils.augmentor.trans_mean_variance_norm
as
trans_mean_variance_norm
...
...
@@ -87,7 +86,10 @@ class DataReader(object):
feature_file_list
,
label_file_list
,
drop_sentence_len
=
512
,
seed
=
1
):
parallel_num
=
10
,
sample_buffer_size
=
1024
,
sample_info_buffer_size
=
10000
,
random_seed
=
0
):
self
.
_drop_sentence_len
=
drop_sentence_len
self
.
_frame_dim
=
120
*
11
self
.
_drop_frame_len
=
256
...
...
@@ -97,8 +99,12 @@ class DataReader(object):
self
.
_label_file_list
=
label_file_list
self
.
_block_info_list
=
None
self
.
_bucket_list
=
None
self
.
_rng
=
random
.
Random
(
random_seed
)
self
.
generate_bucket_list
(
True
)
self
.
_order_id
=
0
self
.
_sample_buffer_size
=
sample_buffer_size
self
.
_sample_info_buffer_size
=
sample_info_buffer_size
self
.
_process_num
=
parallel_num
def
generate_bucket_list
(
self
,
is_shuffle
):
if
self
.
_block_info_list
is
None
:
...
...
@@ -112,10 +118,10 @@ class DataReader(object):
block_label_info_lines
[
i
],
block_label_info_lines
[
i
+
1
])
self
.
_block_info_list
.
append
(
map
(
lambda
x
:
x
.
strip
(),
block_info
))
map
(
lambda
line
:
line
.
strip
(),
block_info
))
if
is_shuffle
:
random
.
shuffle
(
self
.
_block_info_list
)
self
.
_rng
.
shuffle
(
self
.
_block_info_list
)
self
.
_bucket_list
=
[]
for
i
in
xrange
(
0
,
len
(
self
.
_block_info_list
),
self
.
_shuffle_block_num
):
...
...
@@ -133,21 +139,20 @@ class DataReader(object):
def
_sample_generator
(
self
):
manager
=
Manager
()
sample_info_queue
=
manager
.
Queue
(
1024
)
sample_queue
=
manager
.
Queue
(
1024
)
process_num
=
2
sample_info_queue
=
manager
.
Queue
(
self
.
_sample_info_buffer_size
)
sample_queue
=
manager
.
Queue
(
self
.
_sample_buffer_size
)
self
.
_order_id
=
0
def
ordered_feeding_worker
(
sample_info_queue
):
for
sample_info_bucket
in
self
.
_bucket_list
:
sample_info_list
=
sample_info_bucket
.
generate_sample_info_list
(
)
random
.
shuffle
(
sample_info_list
)
# do shuffle here
self
.
_rng
.
shuffle
(
sample_info_list
)
# do shuffle here
for
sample_info
in
sample_info_list
:
sample_info_queue
.
put
((
sample_info
,
self
.
_order_id
))
self
.
_order_id
+=
1
for
i
in
xrange
(
process_num
):
for
i
in
xrange
(
self
.
_
process_num
):
sample_info_queue
.
put
(
EpochEndSignal
())
feeding_thread
=
Thread
(
...
...
@@ -215,7 +220,7 @@ class DataReader(object):
workers
=
[
Process
(
target
=
ordered_processing_worker
,
args
=
args
)
for
_
in
xrange
(
process_num
)
for
_
in
xrange
(
self
.
_
process_num
)
]
for
w
in
workers
:
...
...
@@ -224,7 +229,7 @@ class DataReader(object):
finished_process_num
=
0
while
finished_process_num
<
process_num
:
while
finished_process_num
<
self
.
_
process_num
:
sample
=
sample_queue
.
get
()
if
isinstance
(
sample
,
EpochEndSignal
):
finished_process_num
+=
1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录