2017-06-13 19 views
0

Tensorflowの入力パイプラインに関する問題があります>キューが正しく理解されているかどうかわかりません。Tensorflow FIFOキューが閉じており、要素が不十分です

私は、最初の2つの分離した画像へのパスを生成し、私は1つの画像テンソルと私は新しいキュー

に追加する1つのラベルテンソルのすべてを組み合わせた処理後

paths_queue_mines=tf.train.slice_input_producer([t_pathsMine,t_pathMask,t_labels], 
               shuffle=True) 
paths_queue_bckg=tf.train.slice_input_producer((t_pathBckg,), 
               shuffle=True) 

にラベルを付けslice_input_producerを作成

images_queue=tf.FIFOQueue(capacity=300, 
          dtypes=[tf.float32,tf.float32], 
          shapes=[(SHAPE,SHAPE,1),(SUBDIVISION,SUBDIVISION,5)], 
          name='images_queue') 


enqueue_op=images_queue.enqueue((img_final,label_final)) 
N_threads=20 
#create QueueRunner for filling images_queue 
qr=tf.train.QueueRunner(images_queue,[enqueue_op]*N_threads) 
tf.train.add_queue_runner(qr) 

images_queue.dequeueManyを使用してトレーニングを開始できますが、いくつかのトレーニングステップ(4〜160のバッチサイズ次のエラーが表示されます。

FIFOQueue '_2_Preprocessing/images_queue' is closed and has insufficient elements (requested 64, current size 44) 
    [[Node: images_queue_DequeueMany = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](Preprocessing/images_queue, images_queue_DequeueMany/n)]] 

Caused by op 'images_queue_DequeueMany', defined at: 
    File "main.py", line 194, in <module> 
    run_training() 
    File "main.py", line 114, in run_training 
    images,labels = images_queue.dequeue_many(FLAGS.batch_size) 
    File "/home/thales/anaconda3/lib/python3.5/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/thales/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 1328, in _queue_dequeue_many_v2 
    timeout_ms=timeout_ms, name=name) 
    File "/home/thales/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op 
    op_def=op_def) 
    File "/home/thales/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op 
    original_op=self._default_original_op, op_def=op_def) 
    File "/home/thales/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1228, in __init__ 
    self._traceback = _extract_stack() 

OutOfRangeError (see above for traceback): FIFOQueue '_2_Preprocessing/images_queue' is closed and has insufficient elements (requested 64, current size 44) 
    [[Node: images_queue_DequeueMany = QueueDequeueManyV2[component_types=[DT_FLOAT, DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](Preprocessing/images_queue, images_queue_DequeueMany/n)]] 

キューが閉じている理由はわかりません。内部に十分な画像がない場合でも、プログラムはそれが再び満たされるのを待つべきですが、例外を捕捉して3秒後にもう一度やり直すと、キュー内の同じ数の画像で同じことが起こります。

sliceInputProducer

num_epochsためtensorflowドキュメントに探して:(オプション)整数。指定されていれば、 OutOfRangeエラーを生成する前に、input_producer がnum_epochs回input_tensorの各行を生成します。指定されていない場合、input_producerはinput_tensorの行を無制限に回して を循環させることができます。

スライス入力プロデューサは、すべてのデータを見た後で閉じるべきではありません。

あまりにも重いためキューがすぐにいっぱいになりませんし、しばらくすると閉じられますか?

はあなたの助けをありがとう

+0

エラーを再現する自己完結型コードを貼り付けることができれば助かります。 – npf

+0

この種のエラーは、通常、前処理コード内のオペレーションの1つが失敗し、シャットダウン中にキューが閉じられたことを示します。 'OutOfRangeError'の前に他の例外やエラーメッセージが出力されていますか? – mrry

答えて

0

問題は解決:それは無作為に前処理中にエラーが表示されました。 images_queueが新しいイメージをエンキューしようとしたときにこの例外が発生すると、何も出力されませんが、キューは終了します。その後、キューにアクセスしようとすると、OutOfRangeError

関連する問題