通过遵循mnist示例,我能够构建一个自定义网络,并使用示例的inputs
函数来加载我的数据集(以前编码为TFRecord
)。简单回顾一下,inputs
函数如下所示:
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
然后,在培训期间,我宣布培训操作员和运行一切,一切顺利。在
现在,我尝试使用相同的函数在相同的数据上训练不同的网络,唯一的(主要的)不同之处在于,我没有在某些train_operator
上调用slim.learning.train
函数,而是手动进行训练(通过手动评估损失和更新参数)。建筑更复杂,我不得不这么做。在
当我试图使用inputs
函数生成的数据时,程序会卡住,设置队列超时确实表明它卡在了生产者的队列上。
这让我相信我可能遗漏了关于tensorflow中producer的使用的一些内容,我已经阅读了教程,但是我无法解决这个问题。是否存在调用slim.learning.train
所做的某种初始化,如果我手动进行训练,则需要手动复制?为什么生产商不生产?在
例如,执行以下操作:
^{pr2}$印刷品
<tf.Tensor 'input/shuffle_batch:0' shape=(1, 128, 384, 6) dtype=float32>
哪个是正确的(象征性的?)但是如果我试图用一个imgs.eval()
得到实际的数据,它会被无限期地卡住。在
您需要启动队列运行器,否则队列将是空的,并且从它们读取的数据将挂起。见the documentation on queue runners。在
相关问题 更多 >
编程相关推荐