2017-02-12 4 views
0

私はtfrecordを使ってシーケンスのデータセットを扱っています。 1つの例をメモリに読み込むと、2つのコンテキストフィーチャと1つのシーケンスフィーチャが得られます。コンテキストフィーチャは、シーケンスの長さとシーケンスのラベルです。シーケンスフィーチャは、各タイムステップのフィーチャを表すバイトのリストです。 だから私はすべての例には3つのテンソルがあります関数tf.slice_input_producerテンソルを使ったエラー

length TensorShape([]) 
label TensorShape([]) 
frames TensorShape([Dimension(None)]) 

私はラベルを予測するために、すべてのシーケンス機能を使用したいので、私はラベルがフレームと同じ長さにする必要があります。

length=tf.expand_dims(length, 0, name='expand_length') 
label=tf.expand_dims(label, 0, name='expand_label') 
labels=tf.tile(label, length, name='multi_label') 

私は、次の解像度を取得し、この時間:

labels TensorShape([Dimension(None)]) 
frames TensorShape([Dimension(None)]) 

そして私は、私は1つのフレームとラベルを取得することができるようにキューにそれらをプッシュする必要があります。

frame, label=tf.train.slice_input_producer([frames, labels]) 

次に、それらをバッチしてネットトレーニングルーチンを実行します。

frames, labels = tf.train.shuffle_batch([frame, label], 4, 16, 8) 
それが動作するはずです

、しかし、エラーが関数tf.train.slice_input_producerで起こっここではエラー情報です:

W d:\build\tensorflow\tensorflow_gpu-r0.12\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: indices = 119 is not in [0, 117) 
     [[Node: slice_timestep/Gather = Gather[Tindices=DT_INT32, Tparams=DT_STRING, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](parse_one_ex/parse_one_ex:2, slice_timestep/fraction_of_32_full_Dequeue)]] 
W d:\build\tensorflow\tensorflow_gpu-r0.12\tensorflow\core\framework\op_kernel.cc:975] Invalid argument: indices = 119 is not in [0, 117) 
     [[Node: slice_timestep/Gather = Gather[Tindices=DT_INT32, Tparams=DT_STRING, validate_indices=true, _device="/job:localhost/replica:0/task:0/cpu:0"](parse_one_ex/parse_one_ex:2, slice_timestep/fraction_of_32_full_Dequeue)]] 
I d:\build\tensorflow\tensorflow_gpu-r0.12\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cupti64_80.dll locally 
W d:\build\tensorflow\tensorflow_gpu-r0.12\tensorflow\core\framework\op_kernel.cc:975] Out of range: RandomShuffleQueue '_3_batch_ex/random_shuffle_queue' is closed and has insufficient elements (requested 4, current size 0) 
     [[Node: batch_ex = QueueDequeueMany[_class=["loc:@batch_ex/random_shuffle_queue"], component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch_ex/random_shuffle_queue, batch_ex/n)]] 
W d:\build\tensorflow\tensorflow_gpu-r0.12\tensorflow\core\framework\op_kernel.cc:975] Out of range: RandomShuffleQueue '_3_batch_ex/random_shuffle_queue' is closed and has insufficient elements (requested 4, current size 0) 
     [[Node: batch_ex = QueueDequeueMany[_class=["loc:@batch_ex/random_shuffle_queue"], component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch_ex/random_shuffle_queue, batch_ex/n)]] 
W d:\build\tensorflow\tensorflow_gpu-r0.12\tensorflow\core\framework\op_kernel.cc:975] Out of range: RandomShuffleQueue '_3_batch_ex/random_shuffle_queue' is closed and has insufficient elements (requested 4, current size 0) 
     [[Node: batch_ex = QueueDequeueMany[_class=["loc:@batch_ex/random_shuffle_queue"], component_types=[DT_FLOAT, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch_ex/random_shuffle_queue, batch_ex/n)]] 

slice_input_producerの名前はshuffle_batchの名前slice_timestep

ですis batch_ex

私のテンターボードにグラフがあります。以下は

the whole graph

local zoomed graph

エラーを再現する単純化されたコードです:私は解決してきた

import tensorflow as tf 

context_features = { 
    "length": tf.FixedLenFeature([], dtype=tf.int64), 
    "label": tf.FixedLenFeature([], dtype=tf.int64) 
} 
sequence_features = { 
    "imgs_list": tf.FixedLenSequenceFeature([], dtype=tf.string), 
} 


file=tf.train.string_input_producer(['./train.tfrecord']) 
reader=tf.TFRecordReader() 
_, ex=reader.read(file) 

context_parsed, sequence_parsed = tf.parse_single_sequence_example(
    serialized=ex, 
    context_features=context_features, 
    sequence_features=sequence_features 
) 
length=tf.cast(context_parsed['length'], tf.int32) 
label=tf.cast(context_parsed['label'], tf.int32) 
length=tf.expand_dims(length, 0, name='expand_length') 
label=tf.expand_dims(label, 0, name='expand_label') 
label=tf.tile(label, length) 
imcontent, label=tf.train.slice_input_producer([sequence_parsed['imgs_list'], label]) 
im=tf.image.decode_jpeg(imcontent, 3) 
im=tf.image.resize_images(im, [224, 224]) 
im, label = tf.train.shuffle_batch([im, label], 4, 16, 8, name='batch_ex') 
with tf.Session() as sess: 
    tf.train.start_queue_runners(sess) 
    fig=plt.figure() 
    while(True): 
     [res, res2]=sess.run([im, label]) 
     print(res2) 
+0

あなたのエラー状態 '_3_batch_ex/random_shuffle_queueが閉じられていて、不十分な要素(4、現在のサイズ0が要求されました)を持っています。'私の経験上、通常は入力ファイルから何も読み取ることができないことを示しています。あなたはそれが正しく見つかっていると確信して、十分なものがそこにありますか?それは4つのレコードのセットを読んでゼロを得ようとしていると言います... –

+0

ありがとうございました。私は解決しました。 – mxmxlwlw

答えて

0

。 slice_input_producerは静的なようです。私は使用します

関連する問題