前言

在使用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的更多相关文章

  1. laravel 【error】MethodNotAllowedHttpException No message

    Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message 报错原因[原理]CSRF ...

  2. 【Error】IOError: [Errno 22] invalid mode ('wb') or filename

    错误描述: IOError: [Errno 22] invalid mode ('wb') or filename: 'C:\\Users\\Viral Patel\\Documents\\GitHu ...

  3. 【ERROR】使用jquery的ajax出现error:readyState=4,status=500

    使用jquery的ajax出现error:readyState=4,status=500,ajax代码如下: $.ajax({ url : "../toBeFinMisManage/show ...

  4. 【ERROR】ERROR: transport error 202: bind failed: Cannot assign requested address

    异常信息: ERROR: transport error : bind failed: Cannot assign requested address ERROR: JDWP Transport dt ...

  5. 【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 ...

  6. 【error】'isnan' was not declared in this scope

    error问题 'isnan' was not declared in this scope isnan在cmath中被取消宏定义: // These are possible macros impo ...

  7. 【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_ ...

  8. 【error】scripts/basic/fixdep: Syntax error: "(" unexpected

    前言 第一次安装PCIE驱动的时候容易出现各种问题,总结一下下.. 原因分析 一般情况下,直接make的时候会出现问题. scripts/basic/fixdep: : scripts/basic/f ...

  9. 【error】Invalid ADAPTORNAME specified. Type 'imaqhwinfo' for a list of available ADAPTORNAMEs.

    前言 使用matlab通过摄像头获取图像进行处理: 问题描述 使用matalb调用摄像头时出现错误: >> imaqhwinfo Warning: No Image Acquisition ...

随机推荐

  1. car购车翻译篇

    Sedans 4门轿车 si 运动型车,通常匹配6挡位变速箱 Coupes 双门,有少少跑车的含义 Hatchbacks 掀背   配置英语 Honda Sensing® Standard 感应标准, ...

  2. shiro认证+盐加密

    Shiro认证 导入pom依赖 <shiro.version>1.2.5</shiro.version> <!--shiro--> <dependency&g ...

  3. C语言中【变量】的存储类型共有4种类型

    在C语言中,对变量的存储类型说明有以下四种:   auto          自动变量 (动态存储) register     寄存器变量(动态存储) extern       外部变量(静态存储) ...

  4. spaceclaim脚本(内摆线)

    import math #导入数学模块,因为会使用π def x_comp(k,r,t): #定义x坐标的计算函数 return r * (k -1) * math.cos(t) + r * math ...

  5. RabbitMQ入门学习系列(七) 远程调用RPC

    快速阅读 生产者和消费者启动以后,都有一个接收事件,消费者是接收事件是处理调用方法以后等待生产者的返回,生产者的接收事件是处理接收生产者发送的消息,进行处理.消费者发送的时候要在回调队列中加入一个标识 ...

  6. 登录注册页面模板汇总WEB前端(50套)

    土地指标管理系统入口登录页面 土地指标管理系统入口登录页面.zip: https://u18740809.pipipan.com/fs/18740809-382374353 紫色响应式登录页面模板 紫 ...

  7. 【java/Json】用Java对象构建Json语法树

    本文后续:https://www.cnblogs.com/xiandedanteng/p/11973129.html 编译第一步:将文本解析成Java对象构成的语法树 第二步:将语法树输出整形好的Js ...

  8. 范围指示器Extent Indicators

    范围指示器Extent Indicators 商务合作,科技咨询,版权转让:向日葵,135-4855__4328,xiexiaokui#qq.com   商务合作,科技咨询,版权转让:向日葵,135- ...

  9. gitlab 默认端口修改文件

    vim /var/opt/gitlab/nginx/conf/gitlab-http.conf listen *:80;

  10. disruptor 单生产者多消费者

    demo1 单生产者多消费者创建. maven 依赖 <!-- https://mvnrepository.com/artifact/com.lmax/disruptor --> < ...