上午,准備將一個數據集編碼成TFrecord 格式。然后,總是報錯,下面這個bug一直無法解決,無論是Google,還是github。出現亂碼,提示:
Invalid argument: Could not parse example input, value ‘#######’
這個好像牛頭不對馬嘴,出現在控制台上最后的提示是:
OutOfRangeError (see above for traceback): RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0) [[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_UINT8],
這個博客OutOfRangeError : RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed說,可能是tf.train.shuffle_batch()函數中參數num_threads的原因。於是,我就將這個改成了64,128。線程多了,電腦一下子死機了,中間還不斷輸出亂碼。
這個給我提醒了一下,可能是因為文件輸入來不及讀取完全的緣故。而我處理的文件是遙感圖片tiff,一個圖片(5000,5000,3),一張圖片大概是72M大小。於是我裁剪了圖片(900,900,3),然后程序運行良好。
算是一個坑吧,網上沒找到相關記錄,記錄下,看到的人少走彎路吧~
輸入大文件的時候,完整報錯如下:
2018-06-03 14:50:15.765894: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2018-06-03 14:50:15.766269: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-03 14:50:15.766605: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-03 14:50:15.767003: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-03 14:50:15.767453: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-03 14:50:17.411339: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\framework\op_kernel.cc:1158] Invalid argument: Could not parse example input, value: '
���/
���
label_raw���
���
��������������������������������������
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
return fn(*args)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
status, run_metadata)
File "D:\Anaconda3\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_UINT8], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/experiment/01_try/MLStudy/CAN_Seg/makedataset.py", line 130, in <module>
i, l = sess.run([images, labels]) # 在會話中取出image和label
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
run_metadata_ptr)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 997, in _run
feed_dict_string, options, run_metadata)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1132, in _do_run
target_list, options, run_metadata)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1152, in _do_call
raise type(e)(node_def, op, message)
2018-06-03 14:50:18.943971: W c:\l\tensorflow_1501907206084\work\tensorflow-1.2.1\tensorflow\core\framework\op_kernel.cc:1158] Invalid argument: Could not parse example input, value: '
���/
���
label_raw���
���
���
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_UINT8], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
Caused by op 'shuffle_batch', defined at:
File "E:/experiment/01_try/MLStudy/CAN_Seg/makedataset.py", line 123, in <module>
images, labels = get_batch(filename_queue, batch_size=1)
File "E:/experiment/01_try/MLStudy/CAN_Seg/makedataset.py", line 82, in get_batch
capacity=10, min_after_dequeue=7)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\input.py", line 1217, in shuffle_batch
name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\training\input.py", line 788, in _shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\data_flow_ops.py", line 457, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_data_flow_ops.py", line 946, in _queue_dequeue_many_v2
timeout_ms=timeout_ms, name=name)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2506, in create_op
original_op=self._default_original_op, op_def=op_def)
File "D:\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1269, in __init__
self._traceback = _extract_stack()
OutOfRangeError (see above for traceback): RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_UINT8], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
