2016-11-22 93 views
1

通過遵循mnist示例,我能夠構建自定義網絡並使用示例的inputs函數加載我的數據集(以前編碼爲TFRecord)。只要回顧一下吧,inputs函數看起來像:Tensorflow string_input_producer卡在隊列中

def inputs(train_dir, train, batch_size, num_epochs, one_hot_labels=False): 

    if not num_epochs: num_epochs = None 
    filename = os.path.join(train_dir, 
         TRAIN_FILE if train else VALIDATION_FILE) 

    with tf.name_scope('input'): 
     filename_queue = tf.train.string_input_producer(
      [filename], num_epochs=num_epochs) 

     # Even when reading in multiple threads, share the filename 
     # queue. 
     image, label = read_and_decode(filename_queue) 

     # Shuffle the examples and collect them into batch_size batches. 
     # (Internally uses a RandomShuffleQueue.) 
     # We run this in two threads to avoid being a bottleneck. 
     images, sparse_labels = tf.train.shuffle_batch(
      [image, label], batch_size=batch_size, num_threads=2, 
      capacity=1000 + 3 * batch_size, 
      # Ensures a minimum amount of shuffling of examples. 
      min_after_dequeue=1000) 

    return images, sparse_labels 

然後,在培訓期間,我宣佈了培訓操作和運行的一切,一切進展順利。現在,我試圖使用相同的功能來訓練不同的網絡上的相同的數據,唯一(主要)的區別是,而不是隻調用slim.learning.train函數在某些train_operator,我手動進行培訓(通過手動評估損失和更新參數)。架構更復雜,我不得不這樣做。

當我嘗試使用由inputs函數生成的數據時,程序卡住了,設置隊列超時確實表明它卡在生產者隊列中。 這導致我相信我可能錯過了關於tensorflow中生產者的使用,我已經閱讀了教程,但我無法弄清楚這個問題。是否有一些初始化,調用slim.learning.train確實需要手動複製,如果我手動進行訓練?爲什麼不是生產商生產

例如,做這樣的事情:

imgs, labels = inputs(...) 
print imgs 

打印

<tf.Tensor 'input/shuffle_batch:0' shape=(1, 128, 384, 6) dtype=float32> 

這是正確的(象徵性的?)張量,但如果我再嘗試用imgs.eval()獲取的實際數據是卡住無限期。

+1

你有沒有嘗試在'tf.Session()'中運行它? – Neal

+0

是的,沒有會話它只是告訴你,你需要一個會話來運行'eval()',這個問題是有關隊列沒有被填充或什麼的.. – powder

回答