OutOfRangeError(请参阅上面的回溯):FIFOQueue'_1_batch/fifo_queue'已关闭且元素不足(请求5,当前大小为0) [英] OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 5, current size 0)

查看:872
本文介绍了OutOfRangeError(请参阅上面的回溯):FIFOQueue'_1_batch/fifo_queue'已关闭且元素不足(请求5,当前大小为0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何解决此问题,此错误消息对我定位问题没有用.感谢您的帮助!

i don't know how to solve this problem, this error message is useless for me to locate the problem. Thanks for helping!

这是e.csv,D.csv和F.csv中的数据

here is the data in e.csv, D.csv and F.csv

e.csv: 1,2,3
       4,5,6
       7,8,9
D.csv: 11,12,13
       14,15,16
       17,18,19
F.csv: 21,22,23
       24,25,26
       27,28,29

这是我的代码

here is my code

import tensorflow as tf
import os

file_dir = './KDD2'
fileNameQueue = []
for file in os.listdir(file_dir):
    fileNameQueue.append(file)

print fileNameQueue


filename_queue = tf.train.string_input_producer(fileNameQueue, shuffle=False)

reader = tf.TextLineReader()
key, value = reader.read(filename_queue)

col1,col2,label = tf.decode_csv(value, record_defaults=[[1],[1],[1]])

example = tf.pack([col1,col2])

example_batch, label_batch = tf.train.batch([example, label], batch_size=5)

with tf.Session() as sess:
    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)
    for i in range(10):
        print example_batch.eval()
    coord.request_stop()
    coord.join(threads)

这是错误消息

here is the error message

root@ubuntumagiclab:/home/magiclab/SAE# python try.py 
['e.csv', 'D.csv', 'F.csv']
Traceback (most recent call last):
  File "try.py", line 30, in <module>
    print example_batch.eval()
  File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/framework/ops.py", line 575, in eval
    return _eval_using_default_session(self, feed_dict, self.graph, session)
  File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/framework/ops.py", line 3633, in _eval_using_default_session
    return session.run(tensors, feed_dict)
  File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 766, in run
run_metadata_ptr)
  File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 964, in _run
    feed_dict_string, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 1014, in _do_run
target_list, options, run_metadata)
  File "/usr/local/lib/python2.7/dist-
packages/tensorflow/python/client/session.py", line 1034, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: FIFOQueue '_0_batch/fifo_queue' is closed and has insufficient elements (requested 5, current size 0)
     [[Node: batch = QueueDequeueMany[_class=["loc:@batch/fifo_queue"], component_types=[DT_INT32, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch/fifo_queue, batch/n)]]

Caused by op u'batch', defined at:
  File "try.py", line 24, in <module>
    example_batch, label_batch = tf.train.batch([example, label], batch_size=5)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/input.py", line 692, in batch
    dequeued = queue.dequeue_many(batch_size, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/data_flow_ops.py", line 458, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 1099, in _queue_dequeue_many
timeout_ms=timeout_ms, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
self._traceback = _extract_stack()

OutOfRangeError (see above for traceback): FIFOQueue '_0_batch/fifo_queue' is closed and has insufficient elements (requested 5, current size 0)
 [[Node: batch = QueueDequeueMany[_class=["loc:@batch/fifo_queue"], component_types=[DT_INT32, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch/fifo_queue, batch/n)]]

推荐答案

问题出在文件路径上.请提供如下所示的fileName Queue的完整路径.

Problem is with filepaths. Please provide complete paths as shown below to fileName Queue.

这对我有用:

fileNameQueue.append('/home/****/Desktop/stackoverflow/data/' +file)

希望这会有所帮助.

这篇关于OutOfRangeError(请参阅上面的回溯):FIFOQueue'_1_batch/fifo_queue'已关闭且元素不足(请求5,当前大小为0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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