MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / tf_record_iterator

Function tf_record_iterator

tensorflow/python/lib/io/tf_record.py:158–186  ·  view source on GitHub ↗

An iterator that read the records from a TFRecords file. Args: path: The path to the TFRecords file. options: (optional) A TFRecordOptions object. Yields: Strings. Raises: IOError: If `path` cannot be opened for reading.

(path, options=None)

Source from the content-addressed store, hash-verified

156 instructions=("Use eager execution and: \n"
157 "`tf.data.TFRecordDataset(path)`"))
158def tf_record_iterator(path, options=None):
159 """An iterator that read the records from a TFRecords file.
160
161 Args:
162 path: The path to the TFRecords file.
163 options: (optional) A TFRecordOptions object.
164
165 Yields:
166 Strings.
167
168 Raises:
169 IOError: If `path` cannot be opened for reading.
170 """
171 compression_type = TFRecordOptions.get_compression_type_string(options)
172 with errors.raise_exception_on_not_ok_status() as status:
173 reader = pywrap_tensorflow.PyRecordReader_New(
174 compat.as_bytes(path), 0, compat.as_bytes(compression_type), status)
175
176 if reader is None:
177 raise IOError("Could not open %s." % path)
178 try:
179 while True:
180 try:
181 reader.GetNext()
182 except errors.OutOfRangeError:
183 break
184 yield reader.record()
185 finally:
186 reader.Close()
187
188
189@tf_export(

Callers

nothing calls this directly

Calls 5

IOErrorFunction · 0.85
GetNextMethod · 0.45
recordMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected