描述here加載一些訓練圖像分批,即,基本上是這樣的:培訓VS測試與我使用的是設置隊列
def read_my_file_format(filename_queue):
# ... use a reader + a decoder
def input_pipeline(filenames, batch_size, num_epochs=None):
filename_queue = tf.train.string_input_producer(...)
example, label = read_my_file_format(filename_queue)
example_batch, label_batch = tf.train.shuffle_batch(
[example, label], batch_size=batch_size, ...)
return example_batch, label_batch
def build_net():
batch, label = input_pipeline(...)
y = encoder(batch) # <- build network using the batch
def train():
with tf.Session() as sess:
# ... init vars
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
try:
while not coord.should_stop():
# ... training step
except tf.errors.OutOfRangeError:
print('Done training -- epoch limit reached')
finally:
coord.request_stop()
coord.join(threads)
sess.close()
這就是很好的訓練 - 但是,我怎麼沒看到我可以測試最終的網絡!什麼使我困惑:
- 由
input_pipeline
返回的張量是網絡的一部分。爲了測試,我將不得不更換它? - 我想我可以創建另一個
input_pipeline
進行測試,即使用不同的文件名隊列。然後我可以使用tf.cond
在不同的輸入批次之間切換,但是:如何確保一次只有一個隊列耗盡。我看不到如何訪問不同的隊列以及如何指定它們如何卸載。
基本上,這個問題歸結爲:什麼是測試網絡的規範方式使用tf.train.shuffle_batch
方法構建。
聽起來不錯,我現在仔細看看這個 – fabian789