我是tensorflow的新手,目前正试图从我的数据中生成csv格式的批次。在TensorFlow中,为什么tf.train.shuffle_batch会永久挂起,并且不会返回批次?
我遵循Tensor Flow的Reading Data Tutorial(https://www.tensorflow.org/programmers_guide/reading_data),但由于我的代码永远存在,我一定误解了一些东西。 我使用了教程中的read_my_file_format函数,它工作正常。现在我想训练我的网络实际使用批处理如下:
def input_pipeline(filenames, batch_size, num_epochs=None):
filename_queue = tf.train.string_input_producer(
filenames, num_epochs=num_epochs, shuffle=True)
example, label = read_my_file_format(filename_queue)
print('read_my_file is done')
min_after_dequeue = 10
capacity = min_after_dequeue + 3 * batch_size
example_batch, label_batch = tf.train.shuffle_batch(
[example, label], batch_size=batch_size, capacity=capacity,
min_after_dequeue=min_after_dequeue)
print('all done but the return')
return example_batch, label_batch
with tf.Session() as sess:
batch_size=5
# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
batch_data,batch_label=sess.run(input_pipeline(file_name,batch_size=batch_size))
print('return is done')
print(batch_data,batch_label)
coord.request_stop()
coord.join(threads)
要进行调试的缘故,在上面的代码,我只是想打印的批量输出没有把它送入网络。用我的印刷品,我能够看到它挂起的位置: 返回example_batch,label_batch之前。
我的神经网络已准备就绪,我的数据已经处理完毕,所以这是唯一让我无法继续前进的项目(超新星分类)。你有什么建议或建议吗?我一直坚持这一点。
此外,如果需要,我只有一个输入文件在我的文件名。
谢谢
您确定它不会在'read_my_file_format'函数中挂起,并且将正确的'file_names'传递给'input_pipeline'吗? – eaksan
是的,我检查了这一点,它走出了read_my_file_format:/ – EliseB