|
|
|
@ -16,7 +16,7 @@ Creator package contains some simple reader creator, which could be used in user
|
|
|
|
|
program.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
__all__ = ['np_array', 'text_file']
|
|
|
|
|
__all__ = ['np_array', 'text_file', "RecordIO"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def np_array(x):
|
|
|
|
@ -55,3 +55,22 @@ def text_file(path):
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
return reader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def RecordIO(path):
|
|
|
|
|
"""
|
|
|
|
|
Creates a data reader that outputs record one one by one from given recordio file
|
|
|
|
|
:path: path of recordio file
|
|
|
|
|
:returns: data reader of recordio file
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def reader():
|
|
|
|
|
f = recordio.reader(path)
|
|
|
|
|
while True:
|
|
|
|
|
r = f.read()
|
|
|
|
|
if r is None:
|
|
|
|
|
break
|
|
|
|
|
yield r
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
return reader
|
|
|
|
|