首页 > 编程语言 > 详细

吴裕雄--天生自然 pythonTensorFlow图形数据处理:读取MNIST手写图片数据写入的TFRecord文件

时间:2019-12-19 10:43:29      阅读:81      评论:0      收藏:0      [点我收藏+]
import numpy as np
import tensorflow as tf

from tensorflow.examples.tutorials.mnist import input_data

# 读取文件。
filename_queue = tf.train.string_input_producer(["F:\\output.tfrecords"])
reader = tf.TFRecordReader()
_,serialized_example = reader.read(filename_queue)
# 解析读取的样例。
features = tf.parse_single_example(serialized_example,features={image_raw:tf.FixedLenFeature([],tf.string),pixels:tf.FixedLenFeature([],tf.int64),label:tf.FixedLenFeature([],tf.int64)}) 
images = tf.decode_raw(features[image_raw],tf.uint8)
labels = tf.cast(features[label],tf.int32)
pixels = tf.cast(features[pixels],tf.int32)
sess = tf.Session()

# 启动多线程处理输入数据。
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess,coord=coord)
for i in range(10):
    image, label, pixel = sess.run([images, labels, pixels])
    print(label)

技术分享图片

 

吴裕雄--天生自然 pythonTensorFlow图形数据处理:读取MNIST手写图片数据写入的TFRecord文件

原文:https://www.cnblogs.com/tszr/p/12064986.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!