Reputation: 65
To read tfrecords:
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(...)
TFRecordReader reads examples from a file queue. But how to read a single example from a particular file synchronically(without a queue). like
file_buf = tf.read_file(filename)
serialized_example = get_train_example(file_buf)
features = tf.parse_single_example(...)
how to implement the get_train_example function
Upvotes: 3
Views: 6656
Reputation: 11
used this one
for example in tf.python_io.tf_record_iterator("path_to_your_file"):
result = tf.train.Example.FromString(example)
print(result)
found it here
Upvotes: 1
Reputation: 121
Not sure if this exactly what you're looking for, but you can do it this way without a queue:
tf_record = "path/to/my.tfrecord"
e = tf.python_io.tf_record_iterator(tf_record).next()
single_example = tf.parse_single_example(e, features=features)
Upvotes: 5