Last active
February 4, 2020 16:32
-
-
Save kevashcraft/c32a8a0d61a5282f1af48c8f5e328771 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
with tf.io.TFRecordWriter('examples.tfrecord') as training_file: | |
for features, label in batch: | |
features = { | |
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=[label])), | |
'features': tf.train.Feature(float_list=tf.train.FloatList(value=features)) # expects list, so if numpy use .tolist() and ensure it's 1-D | |
} | |
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