def parse_example_proto(example_serialized):
"""Parses an Example proto containing a training example of an image.
The output of the build_image_data.py image preprocessing script is a dataset
containing serialized Example protocol buffers.
"""
# Dense features in Example proto.
feature_map = {
'image/encoded': tf.FixedLenFeature([], dtype=tf.string,
default_value=''),
'image/class/label': tf.FixedLenFeature([1], dtype=tf.int64,
default_value=-1),
}
with tf.name_scope('decode_tfrecord'):
features = tf.parse_single_example(example_serialized, feature_map)
image = decode_jpeg(features['image/encoded'])
label = tf.cast(features['image/class/label'], dtype=tf.int32)
return image, label
评论列表
文章目录