【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 ...
随机推荐
- CocoaPods加载第三方库
http://code4app.com/article/cocoapods-install-usage
- .net之大文件断点续传
HTML部分 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.a ...
- RookeyFrame 迁移 线下Model 新增属性 迁移 到数据库
在类库 Rookey.BusSys.Operate(类库) -> InitOperate.cs(类) -> App_Start(方法) 添加代码(举例): ToolOperate.Rep ...
- C结构体指针的初步使用
#include <stdio.h> #include <string.h> struct Books { char title[50]; //char author[100] ...
- C变量作用域的分类和优先级
变量从高到低的优先级以下面展示: 1.文件作用域:变量在全局从文件开头到结尾一直有效即全局变量 2.函数作用域也称局部变量 3.代码块作用域:用{}花括号内的定义的变量:都是在代码块{}中有效 如:i ...
- Problem 2 线段树
$des$ 一个无限长的 01 序列,初始全为 0,每次选择一个区间 [l,r] 进行操作,有三种操作:1. l r 将 [l,r] 中所有元素变成 1.2. l r 将 [l,r] 中所有元素变成 ...
- Poj 3261 Milk Patterns(后缀数组+二分答案)
Milk Patterns Case Time Limit: 2000MS Description Farmer John has noticed that the quality of milk g ...
- (21)打鸡儿教你Vue.js
组件化思想: 组件化实现功能模块的复用 高执行效率 开发单页面复杂应用 组件状态管理(vuex) 多组件的混合使用 vue-router 代码规范 vue-router <template> ...
- 2019秋季 关于C语言指针等探索
C语言指针探索 本篇博客由学生所写,如有错误之处,请在评论区留言 1.输出指针所储存的地址,使指针间接访问所储存地址的内容 #include <stdio.h> int main(void ...
- SQL学习笔记(二)
连接查询 数据准备 例1:查询学生信息及学生的成绩 等值连接 此方法会产生笛卡尔积,生成的记录总数=表1的总数*表2的总数,会产生临时表 内连接 select * from 表1 inner join ...