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
原來,一些不同尺寸的,其中圖像,由此引起的問題。雖然我很好奇這個錯誤信息是如何產生的。我不知道不同大小的圖像會如何產生這種錯誤。