读tfrecords文件,一个一个读/按批次读
来源:互联网 发布:指纹软件锁 编辑:程序博客网 时间:2024/05/17 02:38
import tensorflow as tfimport matplotlib.pyplot as plttfrecords_file = '/home/lw/workspace/MicrovideoLSTM/tfrecordData/videoframe.tfrecords'filename_queue = tf.train.string_input_producer([tfrecords_file]) # 根据文件名生成一个队列reader = tf.TFRecordReader() # TFRecordReader 用于读取 TFReacord_, serialized_example = reader.read(filename_queue) # 返回文件名和文件features = tf.parse_single_example(serialized_example, features={ 'label': tf.FixedLenFeature([], tf.int64), 'image_raw' : tf.FixedLenFeature([], tf.string), }) # 取出包含image和label的feature对象..image = tf.decode_raw(features['image_raw'], tf.uint8) # 要结合自己的数据大小来选择tf.uint8,tf.int32image = tf.reshape(image, [20,20]) # image = tf.reshape(image, [128, 128, 3]) ]要与具体的图像大小保持一致,取灰度图与彩色图label = tf.cast(features['label'], tf.int32) # 读取出标签数据image_batch, label_batch = tf.train.shuffle_batch([image, label], batch_size=10, capacity=2000, min_after_dequeue=1000)# 生成批次with tf.Session() as sess: # 开始一个会话 init_op = tf.global_variables_initializer() sess.run(init_op) coord=tf.train.Coordinator() # 设置多线程协调器 threads= tf.train.start_queue_runners(sess = sess, coord=coord)# 开始 Queue Runners (队列运行器) for i in range(2): #example, l = sess.run([image,label]) # 在会话中取出image和label 在队列中一个一个取 example, l = sess.run([image_batch,label_batch]) # 在会话中取出image_batch和label_batch 在队列中按批次取,维度不同 print example.shape print l.shape print l # plt.imshow(example) # 显示单张图像 plt.imshow(example[i,:,:]) # 在批次里面显示单张图像 plt.show() coord.request_stop() coord.join(threads)
阅读全文
0 0
- 读tfrecords文件,一个一个读/按批次读
- tensorflow将CSV文件转为TFrecords文件
- TFRecords 文件的生成和读取
- TensorFlow .tfrecords训练文件生成、使用
- 生成tfrecords文件(29)---《深度学习》
- 批次
- tensorflow中tfrecords文件的save和read
- python小工具--tfrecords文件的制作工具
- 生成TFRecords文件代码(最终版,亲测可用)
- 7.2 TensorFlow笔记(基础篇): 生成TFRecords文件
- 导入一个一个第三方库import 报错头文件不存在
- 解除与SVN关联,不用一个一个的删除文件
- tfrecords notice
- Tfrecords Guide
- 对于二进制文件,我们用java读出一个一个byte,再用system.out.printlin写到文件里,一个一个分析
- JDBC(2):事务,批次处理文件,处理大文件
- TensorFlow基础5:TFRecords文件的存储与读取讲解及代码实现
- Ubuntu下SVN命令行递归添加目录文件(免去一个一个的添加 --force)
- 实验9 根据材料编程
- OpenID Connect:OAuth 2.0协议之上的简单身份层
- 第15课:Spark Streaming源码解读之No Receivers彻底思考 本节课分享Spark Streaming源码解读之No Receivers彻底思考,企业级开发Spark Strea
- Fence Repair
- CodeFroces GYM 2016-2017 ACM-ICPC, Egyptian Collegiate Programming Contest (ECPC 16) B.street(最短路)
- 读tfrecords文件,一个一个读/按批次读
- 今天开始,每天一更,技术养成记!
- 阿里2017年会上马云讲了啥?
- 重要链接保存
- java线程生命周期图(记忆帖)
- 深度学习知识体系
- 两日小记
- 9月12日是个啥日子?在北京最少有5场安全领域重要的的会议!
- Git之删除本地仓库