import tensorflow as tf
files = tf.train.match_filenames_once("/path/to/data.tfrecords-*")#使用该函数来获取文件列表
filename_queue = tf.train.string_input_producer(files,shuffle = True)#使用该函数创建输入队列
#读取并解析一个样本
reader = tf.TFrecordReader()
_,serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
features = {
'i':tf.FixedLenFeature([],tf.int64),
'j':tf.FixedLenFeature([],tf.int64),
})
with tf.Session() as sess:
tf.local_variables_initializer().run()
#打印文件列表
print(sess.run(files))
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess = sess,coord = coord)
for i in range(6):
print(sess.run([features['i'],features['j']]))
coord.request_stop()
coord.join(threads)
输入文件队列(tensorflow)
最新推荐文章于 2019-10-07 15:45:35 发布