描述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