-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix local recordio reader #3479
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ def reader(): | |
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When training on distributed environment, reader should fetch only a part of all the data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @typhoonzero The files will be read file by file. If we need to fetch only part of the data, maybe we can split them to different files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Anyway, will discuss in another issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, thanks. The recordio file will be read entirely to parse the index before reading the first item, so in that case we need to shard the files. |
||
while True: | ||
r = f.read() | ||
if r is None: | ||
break | ||
yield r | ||
yield pickle.loads(r) | ||
f.close() | ||
|
||
return dec.buffered(reader, buf_size) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
requests==2.9.2 | ||
numpy>=1.12 | ||
protobuf==3.1 | ||
recordio | ||
recordio>=0.1.0 | ||
matplotlib | ||
rarfile | ||
scipy>=0.19.0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to
recordio_reader
to indicate it's a reader?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@typhoonzero It's used as
paddle.v2.reader.creator.recordio
, probablyreader
is indicated in the import path.