栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何从示例队列将数据读取到TensorFlow批处理中?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何从示例队列将数据读取到TensorFlow批处理中?

如果您希望使该输入管道正常工作,则需要添加一个异步队列机制来生成大量示例。这是通过创建

atf.RandomShuffleQueue
atf.FIFOQueue
并插入已读取,解码和预处理的JPEG图像来执行的。

您可以使用方便的结构,这些结构将通过

tf.train.shuffle_batch_join
或生成队列和用于运行队列的相应线程
tf.train.batch_join
。这是一个简单的示例。请注意,此代码未经测试:

# Let's assume there is a Queue that maintains a list of all filenames# called 'filename_queue'_, file_buffer = reader.read(filename_queue)# Depre the JPEG imagesimages = []image = depre_jpeg(file_buffer)# Generate batches of images of this size.batch_size = 32# Depends on the number of files and the training speed.min_queue_examples = batch_size * 100images_batch = tf.train.shuffle_batch_join(  image,  batch_size=batch_size,  capacity=min_queue_examples + 3 * batch_size,  min_after_dequeue=min_queue_examples)# Run your network on this batch of images.predictions = my_inference(images_batch)

根据您需要扩展工作的方式,您可能需要运行多个独立的线程来读取/解码/预处理图像并将其转储到示例队列中。Inception / ImageNet模型中提供了此类管道的完整示例。看一下batch_inputs:

https://github.com/tensorflow/models/blob/master/inception/inception/image_processing.py#L407

最后,如果要使用> O(1000)JPEG图像,请记住,单独准备1000个小文件的效率极低。这会大大减慢您的训练速度。

将图像数据集转换TFRecord为Example原型碎片的更强大,更快速的解决方案。这是一个完全有效的脚本,用于将ImageNet数据集转换为这种格式。这是一组说明,用于在包含JPEG图像的任意目录上运行此预处理脚本的通用版本。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/611244.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号