发现了很多与此错误相关的帖子,但没有找到解决方案。
当我开始训练时,我收到以下错误:
OutOfRangeError(参见上面的回溯):FIFOQueue' _1_batch / fifo_queue'关闭且元素不足(请求1,当前大小0) [[Node:batch = QueueDequeueManyV2 [component_types = [DT_DOUBLE,DT_DOUBLE],timeout_ms = -1,_device =" / job:localhost / replica:0 / task:0 / cpu:0"](batch / fifo_queue,batch / n)]]
重要的代码部分如下:
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(tf.local_variables_initializer())
writer = tf.summary.FileWriter("./logs_path/run5", graph=tf.get_default_graph())
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for e in range(10):
_, summary = sess.run([train_step, summary_op])
writer.add_summary(summary, e)
我的管道功能如下:
1)
def get_inputs(batch_size):
filenames = []
for ch in range(num_channels):
for i in range(1):
filenames.append(os.path.join(pipeline_path, "training_ch%d_%d_pipeline.bin" % (ch+1, i)))
filename_queue = tf.train.string_input_producer(filenames)
read_input = _read_pipeline_files(filename_queue)
return _generate_spectrum_label_batch(read_input.spectrum, read_input.label, 1, batch_size, False)
2)
def _read_pipeline_files(queue):
class PipelineRecord(object):
pass
result = PipelineRecord()
reader = tf.FixedLengthRecordReader(record_bytes=2*8*257)
result.key, value = reader.read(queue)
record_bytes = tf.decode_raw(value, tf.float64)
result.spectrum = tf.reshape(tf.strided_slice(record_bytes, [0], [257]), [257])
result.label = tf.reshape(tf.strided_slice(record_bytes, [8*257], [2*257]), [257])
return result
3)
def _generate_spectrum_label_batch(spectrum, label, min_queue_examples, batch_size, shuffle):
if shuffle:
spectrum_batch, label_batch = tf.train.shuffle_batch([spectrum, label],
batch_size=batch_size,
num_threads=8,
capacity=min_queue_examples + 3*batch_size,
min_after_dequeue=min_queue_examples)
else:
spectrum_batch, label_batch = tf.train.batch([spectrum, label],
batch_size=batch_size,
num_threads=1,
capacity=min_queue_examples + 3*batch_size)
return spectrum_batch, label_batch
我多次检查了数据的路径(根据OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 5, current size 0))。路径应该是正确的! .bin-data就在那里。我不知道如何调试。 我多次更改了batch_size,没有任何反应。
谢谢:)