Last active
August 23, 2018 00:48
-
-
Save sdcubber/9cac73da485b3b6334e49a4724650547 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
featdef = { | |
'image': tf.FixedLenFeature(shape=[], dtype=tf.string), | |
'weather_labels': tf.FixedLenFeature(shape=[], dtype=tf.string), | |
'ground_labels': tf.FixedLenFeature(shape=[], dtype=tf.string) | |
} | |
def _parse_record(example_proto, clip=False): | |
"""Parse a single record into image, weather labels, ground labels""" | |
example = tf.parse_single_example(example_proto, featdef) | |
im = tf.decode_raw(example['image'], tf.float32) | |
im = tf.reshape(im, (IM_SIZE, IM_SIZE, 3)) | |
weather = tf.decode_raw(ex['weather_labels'], tf.float32) | |
ground = tf.decode_raw(ex['ground_labels'], tf.float32) | |
return im, weather, ground | |
# Construct a TFRecordDataset | |
ds_train = tf.data.TFRecordDataset('./data/KagglePlanetTFRecord_{}'.format(IM_SIZE)).map(_parse_record) | |
ds_train = ds_train.shuffle(1000).batch(32) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The 12th and 13th lines, the 'ex' should be 'example'.