Skip to content

Instantly share code, notes, and snippets.

@sdcubber
Last active August 23, 2018 00:48
Show Gist options
  • Save sdcubber/9cac73da485b3b6334e49a4724650547 to your computer and use it in GitHub Desktop.
Save sdcubber/9cac73da485b3b6334e49a4724650547 to your computer and use it in GitHub Desktop.
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)
@cl2227619761
Copy link

The 12th and 13th lines, the 'ex' should be 'example'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment