Tensorflow FIFOQueue 错误:FIFOQueue 已关闭且元素不足 [英] Tensorflow FIFOQueue error: FIFOQueue is closed and has insufficient elements

查看:36
本文介绍了Tensorflow FIFOQueue 错误:FIFOQueue 已关闭且元素不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在使用 tensorflow 编写一个程序来验证模型.我使用 FIFOQueue 对输入数据进行排队.例如,我有 50,000 张图像并一次将 100 张图像放入队列.除了最后的迭代外,该程序运行良好.在最后的迭代中,它显示了错误E tensorflow/core/client/tensor_c_api.cc:485] FIFOQueue '_0_path_queue' 已关闭且元素不足(请求 1,当前大小为 0)[[节点:path_queue_Dequeue = QueueDequeue_class=["loc:@path_queue"], component_types=[DT_INT32, DT_BOOL, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"]]"

Now I am using tensorflow to write a program to validate models. I use the FIFOQueue to queue the input data. For example, I have 50,000 images and enqueue 100 images at a time. The program works beautifully except for the final iteration. At the final iteration, it shows the error "E tensorflow/core/client/tensor_c_api.cc:485] FIFOQueue '_0_path_queue' is closed and has insufficient elements (requested 1, current size 0) [[Node: path_queue_Dequeue = QueueDequeue_class=["loc:@path_queue"], component_types=[DT_INT32, DT_BOOL, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"]]"

我认为这是因为它试图将 50,001~50,100 张图像入队,但无法实现.但是,我不需要将这些图像排入队列,也不会使用它们.我怎样才能避免这个错误?

I think that is because it tries to enqueue the 50,001~50,100 images but cannot achieve this. However, I don't need to enqueue these images and will not use them. How can I avoid this error?

另一个问题是,如果我想使用 dequeue_many(100),但是图像总数不能被 100 整除,比如 45678.在这种情况下,tensorflow 会抛出错误.我该如何解决这个问题?

Another question is that if I would like to use dequeue_many(100), however, the total number of images is not divisible by 100, say 45678. In this case, tensorflow will throw an error. How can I solve this?

谢谢.

推荐答案

尝试 dequeue_up_to 而不是 dequeue_many:https://www.tensorflow.org/versions/r0.10/api_docs/python/io_ops.html

希望有帮助!

这篇关于Tensorflow FIFOQueue 错误:FIFOQueue 已关闭且元素不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆