Tensorflow学习之tfrecords_reader
2017-05-03 19:32
477 查看
filename_queue = tf.train.string_input_producer( [filename], num_epochs=num_epochs)
def read_and_decode(filename_queue): reader = tf.TFRecordReader() _, serialized_example = reader.read(filename_queue),# Defaults are not specified since both keys are required. features={ 'image_raw': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64), }) #tf.FixedLenFeature pase FixedLenFeature # Convert from a scalar string tensor (whose single string has # length mnist.IMAGE_PIXELS) to a uint8 tensor with shape # [mnist.IMAGE_PIXELS]. image = tf.decode_raw(features['image_raw'], tf.uint8) image.set_shape([mnist.IMAGE_PIXELS]) # OPTIONAL: Could reshape into a 28x28 image and apply distortions # here. Since we are not applying any distortions in this # example, and the next step expects the image to be flattened # into a vector, we don't bother. # Convert from [0, 255] -> [-0.5, 0.5] floats. image = tf.cast(image, tf.float32) * (1. / 255) - 0.5 # Convert label from a scalar uint8 tensor to an int32 scalar. label = tf.cast(features['label'], tf.int32) return image, label
相关文章推荐
- Tensorflow学习教程------tfrecords数据格式生成与读取
- tensorflow学习——tfreader格式,队列读取数据tf.train.shuffle_batch()
- TensorFlow的学习之路--创建图像训练所需的tfrecords文件
- TensorFlow学习---tf.nn.conv2d实现卷积操作
- TensorFlow学习笔记6----tf.contrib.learn Quickstart
- TensorFlow 学习(一)—— tf.get_variable() vs tf.Variable(),tf.name_scope() vs tf.variable_scope()
- TensorFlow 学习(二)—— tf.Session() 与 tf.Session().run()
- TensorFlow学习记录-- 7.TensorFlow高效读取数据之tfrecord详细解读
- TensorFlow学习笔记12----Creating Estimators in tf.contrib.learn
- TensorFlow 学习(十三)—— tf.app.flags
- Tensorflow构建自己的图片数据集TFrecords
- tensorflow中tfrecords文件的save和read
- Tensorflow之构建自己的图片数据集TFrecords
- TensorFlow学习笔记10----Logging and Monitoring Basics with tf.contrib.learn
- TensorFlow学习(十一):保存TFRecord文件
- tensorflow读取SVHN数据集转为TFrecords格式
- 由浅入深之Tensorflow(3)----数据读取之TFRecords
- Tensorflow API 学习(3)-tf.slice()
- TensorFlow 学习(七) — 常用函数 api、tf.nn 库
- 【tensorflow学习】ptb_reader源码解析