2016-06-30 18 views
1

我正在運行來自TensorFlow的cifar10示例。但是評估有一個問題。TensorFlow - 如何評估每個示例的所有測試集一次且僅有一次

我有一個測試集,我想從它評估每個例子一次也只有一次。但代碼(line 121)現在只能從隊列中(line 126)獲得,這不能保證。我也做了修改,輸入是'.tfrecords'文件。有什麼建議嗎?

預先感謝您。

+0

看來問題是類似於這[一](http://stackoverflow.com/questions/35674073/compute-status-not-found-tensor-name-input-producer-limit-epochs-epochs-not ),但我不知道如何最終解決它。任何幫助,將不勝感激。 – Tengerye

回答

1

創建文件名隊列here的函數tf.train.string_input_producer可以接受參數num_epochs。您可以指定您希望它只運行1個紀元。

# Create a queue that produces the filenames to read. 
filename_queue = tf.train.string_input_producer(filenames, num_epochs=1) 
+0

它背後有一個問題:培訓必須採取不止一個例子的時代;當我加載模型時,TensorFlow會出現以下錯誤。 '在檢查點文件中找不到'input_producer/limit_epochs/epochs'的張量名稱 – Tengerye

0

我已經想出了一個解決方案,但不完善。線索將其從變量中排除以加載並自行初始化limit_epochs。以下是詳細步驟:

添加編碼 del variables_to_restore['input_producer/limit_epochs/epochs']variables_to_restore = variable_averages.variables_to_restore()。它會停止加載input_producer/limit_epochs到模型。

接下來,在會話中添加代碼sess.run(tf.initialize_variables([v for v in tf.all_variables() if v.name.startswith("input_producer")]))以激活變量。

最後,請執行操作filename_queue = tf.train.string_input_producer(filenames, num_epochs=1)

並嘗試在關閉線程之前保存文件。

不完美是你必須讓每個線程只讀一個例子,如果你想它適合任意測試的例子。

相關問題