How do you read all examples from a TFRecords at once?
I've been using tf.parse_single_example
to read out individual examples using code similar to that given in the method read_and_decode
in the example of the fully_connected_reader. However, I want to run the network against my entire validation dataset at once, and so would like to load them in their entirety instead.
I'm not entirely sure, but the documentation seems to suggest I can use tf.parse_example
instead of tf.parse_single_example
to load the entire TFRecords file at once. I can't seem to get this to work though. I'm guessing it has to do with how I specify the features, but I'm not sure how in the feature specification to state that there are multiple examples.
In other words, my attempt of using something similar to:
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_example(serialized_example, features={
'image_raw': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64),
})
isn't working, and I assume it's because the features aren't expecting multiple examples at once (but again, I'm not sure). [This results in an error of ValueError: Shape () must have rank 1
]
Is this the proper way to read all the records at once? And if so, what do I need to change to actually read the records? Thank you much!