【error】OutOfRangeError (see above for traceback): RandomShuffleQueue
前言
在使用tensorflow TFRecord的过程中,读取*.tfrecord文件时出现错误,本文解决这个错误。
错误描述:
OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested , current size )
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT32, DT_FLOAT, DT_FLOAT], timeout_ms=-, _device="/job:localhost/replica:0/task:0/device:CPU:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
源码:
image_batch, label_batch, roi_batch, landmark_batch = tf.train.shuffle_batch([img,label,roi,landmark],
batch_size=batch_size,
capacity=capacity,
min_after_dequeue=min_after_dequeue,
num_threads=7)
错误原因:
在执行训练的时候,队列会被后台的线程填充好。如果设置了最大训练迭代数(epoch),在某些时候,样本出队的操作可能会抛出一个tf.OutOfRangeError的错误。这是因为tensorflow的队列已经到达了最大实际的最大迭代数,没有更多可用的样本了。这也是为何推荐代码模板需要用try..except ..finally结构来处理这种错误。
一般遇到这个错误,代码本身并没有什么问题,基本上都是参数设置不一致或者和不合适导致的,要注意检查各个参数。
对于博主来说,更改的参数有:
1. 数据格式的不一致性,要与生成tfrecord的数据格式保持一致。
features = tf.parse_single_example(serialized_example,
features={
'img':tf.FixedLenFeature([],tf.string),
'label':tf.FixedLenFeature([],tf.int64),
'roi':tf.FixedLenFeature([4],tf.float32),
'landmark':tf.FixedLenFeature([10],tf.float32),
})
将label的数据格式由int32改为int64;
这方面,还有一个更改的地方是输入图像数据的大小。
# img = tf.reshape(img, [48,48,3])
img = tf.reshape(img, [img_size,img_size,3])
这里博主测试的是MTCNN中生成的pos_12_train.tfrecord的数据,故此处img_size应该是12;
2. batch_size的大小;
这个是需要和运行环境匹配的,也就是批量大小过大,系统可能处理不过来造成的;
3. 根据情况可能还有其他参数需要检查,比如num_epochs、num_threads等等。
4. 也可以更换更好的硬件设备,比如更好的GPU显卡;
参考
1. 理解tfrecord读取数据;
2. TensorFlow bug;
完
【error】OutOfRangeError (see above for traceback): RandomShuffleQueue的更多相关文章
- laravel 【error】MethodNotAllowedHttpException No message
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message 报错原因[原理]CSRF ...
- 【Error】IOError: [Errno 22] invalid mode ('wb') or filename
错误描述: IOError: [Errno 22] invalid mode ('wb') or filename: 'C:\\Users\\Viral Patel\\Documents\\GitHu ...
- 【ERROR】使用jquery的ajax出现error:readyState=4,status=500
使用jquery的ajax出现error:readyState=4,status=500,ajax代码如下: $.ajax({ url : "../toBeFinMisManage/show ...
- 【ERROR】ERROR: transport error 202: bind failed: Cannot assign requested address
异常信息: ERROR: transport error : bind failed: Cannot assign requested address ERROR: JDWP Transport dt ...
- 【ERROR】no matching function for call to 'std::basic_ifstream<char>::basic_ifstream
错误记录:QT中使用 no matching function for call to 'std::basic_ifstream<char>::basic_ifstream(QString ...
- 【error】'isnan' was not declared in this scope
error问题 'isnan' was not declared in this scope isnan在cmath中被取消宏定义: // These are possible macros impo ...
- 【error】no type named ‘type’ in ‘class std::result_of<void
Q: std::thread fs_module(fs_process, prob_orig, fb_sz, line_num, probp, plabel, std::ref(confidence_ ...
- 【error】scripts/basic/fixdep: Syntax error: "(" unexpected
前言 第一次安装PCIE驱动的时候容易出现各种问题,总结一下下.. 原因分析 一般情况下,直接make的时候会出现问题. scripts/basic/fixdep: : scripts/basic/f ...
- 【error】Invalid ADAPTORNAME specified. Type 'imaqhwinfo' for a list of available ADAPTORNAMEs.
前言 使用matlab通过摄像头获取图像进行处理: 问题描述 使用matalb调用摄像头时出现错误: >> imaqhwinfo Warning: No Image Acquisition ...
随机推荐
- 【CSS】div
一.div內容溢出 .remark-div { overflow: auto; height: auto; max-height: 100px; } 1.溢出 overflow :auto时,内容超过 ...
- 83: 模拟赛 树形dp
$des$ $sol$ 维护每个点的子树中的信息以及非子树的信息 $code$ #include <bits/stdc++.h> using namespace std; #define ...
- Python之☞float浮点数精度问题
Python的浮点数损失精度问题(转) 一个简单的面试题: >>>0.1+0.1+0.1 0.2 >>>0.1+0.1+0.1 0.3000000000000000 ...
- python中is 和== 比较的区别?
is 比较两个对象的内存地址是否相同, == 比较连个对象的数据是否相等
- 数据库已经最优,每次操作50万条数据,怎么提高API接口的速度?
第一种可以使用负载均衡,10台,就每台5W条数据第二种每台机器.可以把添加任务队列.利用多线程解决IO密集型任务的特点.第三种利用异步协程方式提高调度行为
- Tkinter 之NoteBook选项卡标签
一.参数说明 参数 作用 width 选项卡宽度,单位像素 height 选项卡高度 cursor 鼠标停留的样式 padding 外部空间填充,是个最多4个元素的列表 style 设置menubo ...
- 超级详细的git使用指北
原文地址:https://www.cnblogs.com/wupeixuan/p/11947343.html 1.0 安装和配置 1.1 Git 安装 1.2 Git 配置 2.0 Git 基 ...
- [内网渗透]IPC$共享连接
0x01 简介 IPC$(Internet Process Connection)是共享"命名管道"的资源,它是为了让进程间通信而开放的命名管道,可以通过验证用户名和密码获得相应的 ...
- fluent-动网格-动态层
模型算例来源:http://blog.sina.com.cn/s/blog_599d8faa0100w4uj.html 原视频下载地址:http://yunpan.cn/cujM2FxLuGdLK ...
- Git的使用(2) —— 本地版本库的操作
1. 向本地版本库中添加文件 注意:.git文件夹是本地版本库,包含.git文件夹的目录叫工作目录,要往本地版本库中添加文件,就必须将文件放在工作目录中. (1) 把文件添加到工作目录中. (2) 右 ...