1
我正在通过对不同图像进行训练来测试模型。我有不同的文件夹,其中有不同数量的图像。当我从一个只有20个图像的文件夹更改为100个或10'000个图像的文件夹时,程序立即崩溃,抱怨随机洗牌队列的元素数量不足。张量流随机洗牌队列:元素不足
我没有改变代码中的其他东西,只是将它指向不同的目录,这绝对不是空的。有没有人有一个想法,为什么发生这种情况,以及如何解决它?
错误消息
tensorflow/core/kernels/queue_base.cc:294] _0_READ_DATA/input_producer: Skipping cancelled enqueue attempt with queue not closed
Traceback (most recent call last):
File "test_vgg19.py", line 102, in <module>
images, labels = sess.run([imb_batch1,label_batch1])
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 766, in run
run_metadata_ptr)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 964, in _run
feed_dict_string, options, run_metadata)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
target_list, options, run_metadata)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_3_READ_DATA/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 30, current size 0)
[[Node: READ_DATA/shuffle_batch = QueueDequeueMany[_class=["loc:@READ_DATA/shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](READ_DATA/shuffle_batch/random_shuffle_queue, READ_DATA/shuffle_batch/n)]]
Caused by op u'READ_DATA/shuffle_batch', defined at:
File "test_vgg19.py", line 56, in <module>
imb_batch1,label_batch1 = input_pipeline()
File "test_vgg19.py", line 53, in input_pipeline
min_after_dequeue=min_after_dequeue)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/training/input.py", line 917, in shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "/home/ssoderli/.local/lib/python2.7/site-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 "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 1099, in _queue_dequeue_many
timeout_ms=timeout_ms, name=name)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/ssoderli/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
self._traceback = _extract_stack()
OutOfRangeError (see above for traceback): RandomShuffleQueue '_3_READ_DATA/shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 30, current size 0)
[[Node: READ_DATA/shuffle_batch = QueueDequeueMany[_class=["loc:@READ_DATA/shuffle_batch/random_shuffle_queue"], component_types=[DT_FLOAT, DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](READ_DATA/shuffle_batch/random_shuffle_queue, READ_DATA/shuffle_batch/n)]]
输入管道 - 代码段
def read_my_file_format(filename_queue):
reader = tf.WholeFileReader()
key, record_string = reader.read(filename_queue)
example = tf.image.decode_png(record_string)
return example, key
def input_pipeline(bsize=30, num_epochs=None):
filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once("/home/20images/*.png"), num_epochs=num_epochs, shuffle=True)
example, label = read_my_file_format(filename_queue)
min_after_dequeue = bsize
capacity = min_after_dequeue + 3 * 8
example_batch, label_batch = tf.train.shuffle_batch(
[example, label], batch_size=bsize, capacity=capacity,
min_after_dequeue=min_after_dequeue)
return example_batch, label_batch
EDIT
原来,一些不同尺寸的,其中图像,由此引起的问题。虽然我很好奇这个错误信息是如何产生的。我不知道不同大小的图像会如何产生这种错误。