TensorFlow筆記博客:https://blog.csdn.net/xierhacker/article/category/6511974
寫入tfrecord文件
import tensorflow as tf # 寫入的文件的路徑 file_path = '' # 等待寫入的數組 list = [] writer = tf.python_io.TFRecordWriter(file_path) example = tf.train.Example(features=tf.train.Features(feature={ "label": tf.train.Feature(int64_list=tf.train.Int64List(value=list)) })) writer.write(example.SerializeToString())
讀取tfrecord文件
import tensorflow as tf for serialized_example in tf.python_io.tf_record_iterator("文件的完整路徑"): example = tf.train.Example() example.ParseFromString(serialized_example) label = example.features.feature['label'].int64_list.value # 可以做一些預處理之類的 print(label)
https://blog.csdn.net/huplion/article/details/79600219