Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2da240c7
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2da240c7
编写于
8月 14, 2017
作者:
H
Helin Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix local recordio reader
上级
f80fea8d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
30 addition
and
4 deletion
+30
-4
python/paddle/v2/reader/creator.py
python/paddle/v2/reader/creator.py
+8
-4
python/paddle/v2/reader/tests/creator_test.py
python/paddle/v2/reader/tests/creator_test.py
+22
-0
python/paddle/v2/reader/tests/test_reader_recordio.dat
python/paddle/v2/reader/tests/test_reader_recordio.dat
+0
-0
未找到文件。
python/paddle/v2/reader/creator.py
浏览文件 @
2da240c7
...
...
@@ -57,7 +57,7 @@ def text_file(path):
return
reader
def
recordio
_local
(
paths
,
buf_size
=
100
):
def
recordio
(
paths
,
buf_size
=
100
):
"""
Creates a data reader from given RecordIO file paths separated by ",",
glob pattern is supported.
...
...
@@ -67,15 +67,19 @@ def recordio_local(paths, buf_size=100):
import
recordio
as
rec
import
paddle.v2.reader.decorator
as
dec
import
cPickle
as
pickle
def
reader
():
a
=
','
.
join
(
paths
)
f
=
rec
.
reader
(
a
)
if
isinstance
(
paths
,
basestring
):
path
=
paths
else
:
path
=
","
.
join
(
paths
)
f
=
rec
.
reader
(
path
)
while
True
:
r
=
f
.
read
()
if
r
is
None
:
break
yield
r
yield
pickle
.
loads
(
r
)
f
.
close
()
return
dec
.
buffered
(
reader
,
buf_size
)
...
...
python/paddle/v2/reader/tests/creator_test.py
浏览文件 @
2da240c7
...
...
@@ -34,5 +34,27 @@ class TestTextFile(unittest.TestCase):
self
.
assertEqual
(
e
,
str
(
idx
*
2
)
+
" "
+
str
(
idx
*
2
+
1
))
class
TestRecordIO
(
unittest
.
TestCase
):
def
do_test
(
self
,
path
):
reader
=
paddle
.
v2
.
reader
.
creator
.
recordio
(
path
)
idx
=
0
for
e
in
reader
():
if
idx
==
0
:
self
.
assertEqual
(
e
,
(
1
,
2
,
3
))
elif
idx
==
1
:
self
.
assertEqual
(
e
,
(
4
,
5
,
6
))
idx
+=
1
self
.
assertEqual
(
idx
,
2
)
def
test_recordIO
(
self
):
self
.
do_test
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"test_reader_recordio.dat"
))
self
.
do_test
([
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"test_reader_recordio.dat"
)
])
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/v2/reader/tests/test_reader_recordio.dat
0 → 100644
浏览文件 @
2da240c7
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录