3 Upvotes

Reading an Example from Tensorflow Records File

Python
Other

This will read a single example from a collection of tensorflow record files and print out the format of the first record. This will show the key and value for each feature.

FILENAMES = tf.io.gfile.glob(r'data\train_tfrecords\ld_train*.tfrec')

for tf_rec in FILENAMES:
    raw_dataset = tf.data.TFRecordDataset(tf_rec)
    for raw_record in raw_dataset.take(1):
        example = tf.train.Example()
        example.ParseFromString(raw_record.numpy())
        print(example)
    

By detro - Last Updated Dec. 5, 2020, 4:50 p.m.

Did you find this snippet useful?

Sign up to bookmark this in your snippet library

COMMENTS
RELATED SNIPPETS
Top Contributors
75