Last active
February 7, 2020 18:49
-
-
Save kevashcraft/dbbeedc5c751ab622ac63d91658fb833 to your computer and use it in GitHub Desktop.
Writing a TFRecord File
This file contains 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
# Write a ambient, target, and label data to a TFRecords file | |
with tf.io.TFRecordWriter('examples.tfrecord') as training_file: | |
for ambient, target, label in batch: # batch is a list of (ambient, target, label) tuples | |
features = { | |
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=[label])), | |
'ambient': tf.train.Feature(float_list=tf.train.FloatList(value=ambient.tolist())), # ambient is a 1-D np array | |
'target': tf.train.Feature(float_list=tf.train.FloatList(value=target.tolist())) # target is a 1-D np array | |
} | |
example_proto = tf.train.Example(features=tf.train.Features(feature=features)) | |
training_file.write(example_proto.SerializeToString()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment