Python tensorflow.python.pywrap_tensorflow.PyRecordReader_New() Examples
The following are 10
code examples of tensorflow.python.pywrap_tensorflow.PyRecordReader_New().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.python.pywrap_tensorflow
, or try the search function
.
Example #1
Source File: tf_record.py From lambda-packs with MIT License | 5 votes |
def tf_record_iterator(path, options=None): """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. """ compression_type = TFRecordOptions.get_compression_type_string(options) with errors.raise_exception_on_not_ok_status() as status: reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(path), 0, compat.as_bytes(compression_type), status) if reader is None: raise IOError("Could not open %s." % path) while True: try: with errors.raise_exception_on_not_ok_status() as status: reader.GetNext(status) except errors.OutOfRangeError: break yield reader.record() reader.Close()
Example #2
Source File: event_file_loader.py From lambda-packs with MIT License | 5 votes |
def __init__(self, file_path): if file_path is None: raise ValueError('A file path is required') file_path = resource_loader.readahead_file_path(file_path) logging.debug('Opening a record reader pointing at %s', file_path) with errors.raise_exception_on_not_ok_status() as status: self._reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(file_path), 0, compat.as_bytes(''), status) # Store it for logging purposes. self._file_path = file_path if not self._reader: raise IOError('Failed to open a record reader pointing to %s' % file_path)
Example #3
Source File: tf_record.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def tf_record_iterator(path, options=None): """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. """ compression_type = TFRecordOptions.get_compression_type_string(options) with errors.raise_exception_on_not_ok_status() as status: reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(path), 0, compat.as_bytes(compression_type), status) if reader is None: raise IOError("Could not open %s." % path) while True: try: with errors.raise_exception_on_not_ok_status() as status: reader.GetNext(status) except errors.OutOfRangeError: break yield reader.record() reader.Close()
Example #4
Source File: event_file_loader.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def __init__(self, file_path): if file_path is None: raise ValueError('A file path is required') file_path = resource_loader.readahead_file_path(file_path) logging.debug('Opening a record reader pointing at %s', file_path) with errors.raise_exception_on_not_ok_status() as status: self._reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(file_path), 0, compat.as_bytes(''), status) # Store it for logging purposes. self._file_path = file_path if not self._reader: raise IOError('Failed to open a record reader pointing to %s' % file_path)
Example #5
Source File: event_file_loader.py From deep_image_model with Apache License 2.0 | 5 votes |
def __init__(self, file_path): if file_path is None: raise ValueError('A file path is required') file_path = resource_loader.readahead_file_path(file_path) logging.debug('Opening a record reader pointing at %s', file_path) with errors.raise_exception_on_not_ok_status() as status: self._reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(file_path), 0, compat.as_bytes(''), status) # Store it for logging purposes. self._file_path = file_path if not self._reader: raise IOError('Failed to open a record reader pointing to %s' % file_path)
Example #6
Source File: event_file_loader.py From tensorboard with Apache License 2.0 | 5 votes |
def _make_tf_record_iterator(file_path): """Returns an iterator over TF records for the given tfrecord file.""" # If we don't have TF at all, use the stub implementation. if tf.__version__ == "stub": # TODO(#1711): Reshape stub implementation to fit tf_record_iterator API # rather than needlessly emulating the old PyRecordReader_New API. logger.debug("Opening a stub record reader pointing at %s", file_path) return _PyRecordReaderIterator( tf.pywrap_tensorflow.PyRecordReader_New, file_path ) # If PyRecordReader exists, use it, otherwise use tf_record_iterator(). # Check old first, then new, since tf_record_iterator existed previously but # only gained the semantics we need at the time PyRecordReader was removed. # # TODO(#1711): Eventually remove PyRecordReader fallback once we can drop # support for TF 2.1 and prior, and find a non-deprecated replacement for # tf.compat.v1.io.tf_record_iterator. try: from tensorflow.python import pywrap_tensorflow py_record_reader_new = pywrap_tensorflow.PyRecordReader_New except (ImportError, AttributeError): py_record_reader_new = None if py_record_reader_new: logger.debug("Opening a PyRecordReader pointing at %s", file_path) return _PyRecordReaderIterator(py_record_reader_new, file_path) else: logger.debug("Opening a tf_record_iterator pointing at %s", file_path) # TODO(#1711): Find non-deprecated replacement for tf_record_iterator. with _silence_deprecation_warnings(): return tf.compat.v1.io.tf_record_iterator(file_path)
Example #7
Source File: event_file_loader.py From tensorboard with Apache License 2.0 | 5 votes |
def __init__(self, py_record_reader_new, file_path): """Constructs a _PyRecordReaderIterator for the given file path. Args: py_record_reader_new: pywrap_tensorflow.PyRecordReader_New file_path: file path of the tfrecord file to read """ with tf.compat.v1.errors.raise_exception_on_not_ok_status() as status: self._reader = py_record_reader_new( tf.compat.as_bytes(file_path), 0, tf.compat.as_bytes(""), status ) if not self._reader: raise IOError( "Failed to open a record reader pointing to %s" % file_path )
Example #8
Source File: tf_record.py From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License | 5 votes |
def tf_record_iterator(path, options=None): """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. """ compression_type = TFRecordOptions.get_compression_type_string(options) with errors.raise_exception_on_not_ok_status() as status: reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(path), 0, compat.as_bytes(compression_type), status) if reader is None: raise IOError("Could not open %s." % path) while True: try: with errors.raise_exception_on_not_ok_status() as status: reader.GetNext(status) except errors.OutOfRangeError: break yield reader.record() reader.Close()
Example #9
Source File: tf_record.py From keras-lambda with MIT License | 5 votes |
def tf_record_iterator(path, options=None): """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. """ compression_type = TFRecordOptions.get_compression_type_string(options) with errors.raise_exception_on_not_ok_status() as status: reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(path), 0, compat.as_bytes(compression_type), status) if reader is None: raise IOError("Could not open %s." % path) while True: try: with errors.raise_exception_on_not_ok_status() as status: reader.GetNext(status) except errors.OutOfRangeError: break yield reader.record() reader.Close()
Example #10
Source File: event_file_loader.py From keras-lambda with MIT License | 5 votes |
def __init__(self, file_path): if file_path is None: raise ValueError('A file path is required') file_path = resource_loader.readahead_file_path(file_path) logging.debug('Opening a record reader pointing at %s', file_path) with errors.raise_exception_on_not_ok_status() as status: self._reader = pywrap_tensorflow.PyRecordReader_New( compat.as_bytes(file_path), 0, compat.as_bytes(''), status) # Store it for logging purposes. self._file_path = file_path if not self._reader: raise IOError('Failed to open a record reader pointing to %s' % file_path)