fifo_queue中OutOfRangeError的原因
OutOfRangeError
错误信息为:
padding_fifo_queue is closed and has insufficient elements (required 1 current size 0)
[[Node: get_batch/batch = QueueDequeueManyV2[component_types=[DT_STRING, DT_FLOAT, DT_INT32, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](get_batch/batch/padding_fiflo_queue, get_batch/batch/n)]]
错误原因
这个错误耗费了我整整两天的时间,主要原因在于tensorflow中报错是insufficient elements,让我认为时queue设置参数有误导致的问题,但其实不然。真正原因是输入数据的问题。
对于检测应用,输入的图像尺寸与对应xml文件中记录的图像尺寸(h, w)不一致,从而引起了该错误。
该原因从属于输入reshape时shape不一致
这一范畴。
而该错误(图像保存后的尺寸与xml记录尺寸不一致)的原因在于使用plt.save
保存图像时,图像尺寸有时会发生一个像素单位的偏差(真的坑,万万没想到)。
其他可能原因:data preprocessing
Problem solved : it was an error that randomly appears during the preprocessing. When my images_queue
tries to enqueue a new image and raise this exception, nothing is printed but the queue closes. Then later when I try to access the queue, it raises the OutOfRangeError
.
来源于该网址
其他可能原因:文件末尾的空行
I had the exactly same issue today and later I found it was the input data file I downloaded from “famous data set” (such as https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data) that caused the error: It has some empty lines at the end of the file. Remove the empty lines, the error was gone!
来源于该网址
其他可能原因:输入reshape时shape不一致
You’re likely processing the parsed TFRecord example wrong. E.g. trying to reshape a tensor to an incompatible size. You can debug using a tf_record_iterator to confirm the data you’re reading is stored the way you think it is:
import tensorflow as tf
import numpy as np
tfrecords_filename = '/path/to/some.tfrecord'
record_iterator = tf.python_io.tf_record_iterator(path=tfrecords_filename)
for string_record in record_iterator:
# Parse the next example
example = tf.train.Example()
example.ParseFromString(string_record)
# Get the features you stored (change to match your tfrecord writing code)
height = int(example.features.feature['height']
.int64_list
.value[0])
width = int(example.features.feature['width']
.int64_list
.value[0])
img_string = (example.features.feature['image_raw']
.bytes_list
.value[0])
# Convert to a numpy array (change dtype to the datatype you stored)
img_1d = np.fromstring(img_string, dtype=np.float32)
# Print the image shape; does it match your expectations?
print(img_1d.shape)
Phew, that was a rough bug
, but your answer solved it. I had a tf.py_func node that returned the wrong type, but TF only shows a misleading error message about insufficient elements. – Lenar Hoyt Jun 15 ‘17 at 18:46
来源于网址
其他可能原因:未初始化local variables
I had a similar problem. Digging around the web, it turned out that if you use some num_epochs argument, you have to initialize all the local variables, so your code should end up looking like:
with tf.Session() as sess:
sess.run(tf.local_variables_initializer())
sess.run(tf.global_variables_initializer())
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
# do your stuff here
coord.request_stop()
coord.join(threads)
Queue详解
上一篇: 详解Golang中Channel的用法
下一篇: java队列(Queue)用法总结
推荐阅读
-
在Docker容器中不需要运行sshd的原因浅析
-
无线信号受影响的原因以及在现有的环境中改善信号传输质量的方法
-
java中switch case语句需要加入break的原因解析
-
Vue中 v-if/v-show/插值表达式导致闪现的原因及解决办法
-
浅析jquery ajax异步调用方法中不能给全局变量赋值的原因及解决方法
-
造成便秘的原因有哪些,生活中哪些食物可以缓解便秘
-
Google Adwords 中针对转换率低的关键字的原因分析
-
清朝在“鸦片战争”中失败的根本原因是什么?
-
微信小程序中hidden不生效原因的解决办法
-
电脑使用浏览器中打开网页提示请不要使用非法的url地址访问的原因及解决方法