1. import numpy as np
  2. import tensorflow as tf
  3.  
  4. from tensorflow.examples.tutorials.mnist import input_data
  5.  
  6. # 读取文件。
  7. filename_queue = tf.train.string_input_producer(["F:\\output.tfrecords"])
  8. reader = tf.TFRecordReader()
  9. _,serialized_example = reader.read(filename_queue)
  1. # 解析读取的样例。
  2. features = tf.parse_single_example(serialized_example,features={'image_raw':tf.FixedLenFeature([],tf.string),'pixels':tf.FixedLenFeature([],tf.int64),'label':tf.FixedLenFeature([],tf.int64)})
  1. images = tf.decode_raw(features['image_raw'],tf.uint8)
  2. labels = tf.cast(features['label'],tf.int32)
  3. pixels = tf.cast(features['pixels'],tf.int32)
  1. sess = tf.Session()
  2.  
  3. # 启动多线程处理输入数据。
  4. coord = tf.train.Coordinator()
  5. threads = tf.train.start_queue_runners(sess=sess,coord=coord)
  1. for i in range(10):
  2. image, label, pixel = sess.run([images, labels, pixels])
  3. print(label)

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

  1. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:数据集高层操作

    import tempfile import tensorflow as tf # 1. 列举输入文件. # 输入数据生成的训练和测试数据. train_files = tf.train.match_ ...

  2. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:数据集基本使用方法

    import tempfile import tensorflow as tf # 1. 从数组创建数据集. input_data = [1, 2, 3, 5, 8] dataset = tf.dat ...

  3. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:输入数据处理框架

    import tensorflow as tf # 1. 创建文件列表,通过文件列表创建输入文件队列 files = tf.train.match_filenames_once("F:\\o ...

  4. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:输入文件队列

    import tensorflow as tf # 1. 生成文件存储样例数据. def _int64_feature(value): return tf.train.Feature(int64_li ...

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

    import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_dat ...

  6. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:图像预处理完整样例

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #随机调整图片的色彩,定义两种顺序. def di ...

  7. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:TensorFlow图像处理函数

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt #读取图片 image_raw_data = tf ...

  8. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:循环神经网络预测正弦函数

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt # 定义RNN的参数. HIDDEN_SIZE = ...

  9. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:多线程队列操作

    import tensorflow as tf #1. 定义队列及其操作. queue = tf.FIFOQueue(100,"float") enqueue_op = queue ...

随机推荐

  1. 实战 迁移学习 VGG19、ResNet50、InceptionV3 实践 猫狗大战 问题

    实战 迁移学习 VGG19.ResNet50.InceptionV3 实践 猫狗大战 问题   参考博客:::https://blog.csdn.net/pengdali/article/detail ...

  2. 用Python复制文件的9个方法(转)

    转自:https://zhuanlan.zhihu.com/p/35725217 用Python复制文件的9个方法 Python 中有许多“开盖即食”的模块(比如 os,subprocess 和 sh ...

  3. 【LeetCode】验证二叉搜索树

    [问题]给定一个二叉树,判断其是否是一个有效的二叉搜索树. 假设一个二叉搜索树具有如下特征:节点的左子树只包含小于当前节点的数.节点的右子树只包含大于当前节点的数.所有左子树和右子树自身必须也是二叉搜 ...

  4. C++编程学习(三)运算符

    一.运算符 1.求余运算双方必须是整数. 2.编程时一定要注意运算符的优先级!!!例如: int a=5,b=6,c=6,k; 3>4 //结果为假 a<b //结果为真 k= b!=c ...

  5. C++ STD Gems03

    transform.for_each #include <iostream> #include <vector> #include <string> #includ ...

  6. 大二暑假第一周总结--初次安装配置Hadoop

    本次配置主要使用的教程:http://dblab.xmu.edu.cn/blog/install-hadoop-in-centos/ 以下是自己在配置中的遇到的一些问题和解决方法,或者提示 一.使用虚 ...

  7. [Mathematics][MIT 18.03] Detailed Explanation of the Frequency Problems in Second-Order Differential Equation of Oscillation System

    Well, to begin with, I'd like to say thank you to MIT open courses twice. It's their generosity that ...

  8. 服务器io资源查看

    资源查看命令安装 yum provides /usr/bin/find #查看命令是哪个软件包安装的 执行 yum provides */netstat 命令就可以看到提供命令的工具包net-tool ...

  9. SAP_MM常用代码

    1.采购申请创建/修改/查看:ME51N/ME52N/ME53N 2.采购申请审批:ME54N 3.采购订单创建/修改/查看:ME21N/ME22N/ME23N 4.单个采购订单审批:ME29N 5. ...

  10. Caused by: com.mysql.cj.exceptions.DataReadException: Zero date value prohibited

    原因:数据库日期出现零值,即0000-00-00 属于一个无效日期. 解决方案:重新赋值,或者在jdbc链接后加参数zeroDateTimeBehavior=convertToNull