我拼命想在程序中找到错误。我一直收到以下错误:
[[Node: input_producer/limit_epochs/CountUpTo = CountUpTo[T=DT_INT64, _class=["loc:@input_producer/limit_epochs/epochs"], limit=1, _device="/job:localhost/replica:0/task:0/cpu:0"](input_producer/limit_epochs/epochs)]]
Traceback (most recent call last):
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1039, in _do_call
return fn(*args)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1021, in _run_fn
status, run_metadata)
File "/media/home/user/.conda/envs/tf/lib/python3.6/contextlib.py", line 89, in __exit__
next(self.gen)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.OutOfRangeError: FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 3, current size 0)
[[Node: batch = QueueDequeueUpToV2[component_types=[DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch/fifo_queue, batch/n)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_tfr.py", line 60, in <module>
res = sess.run(item_cont_b)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 982, in _run
feed_dict_string, options, run_metadata)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run
target_list, options, run_metadata)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 3, current size 0)
[[Node: batch = QueueDequeueUpToV2[component_types=[DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch/fifo_queue, batch/n)]]
Caused by op 'batch', defined at:
File "test_tfr.py", line 48, in <module>
allow_smaller_final_batch=True)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/training/input.py", line 917, in batch
name=name)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/training/input.py", line 710, in _batch
dequeued = queue.dequeue_up_to(batch_size, name=name)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/data_flow_ops.py", line 499, in dequeue_up_to
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 1420, in _queue_dequeue_up_to_v2
timeout_ms=timeout_ms, name=name)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
op_def=op_def)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/media/home/user/.conda/envs/tf/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1228, in __init__
self._traceback = _extract_stack()
OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 3, current size 0)
[[Node: batch = QueueDequeueUpToV2[component_types=[DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](batch/fifo_queue, batch/n)]]
我正在使用TF版本1.1.0,tfrecords-FIle是40GB大,包含1.6M示例。我的脚本(如下所示)与 201704_test.tfrecords 位于同一文件夹中,我试图从中读取。当前的批量大小,容量和循环范围只是任意选择进行测试。尝试在GitHub和StackOverFlow中提到的一些事情我一直被困在这里。
我的剧本
import os
import numpy as np
import tensorflow as tf
def read_and_decode(filename_queue):
reader = tf.TFRecordReader()
_, serialized_example = reader.read(filename_queue)
features = tf.parse_single_example(
serialized_example,
features={
'user': tf.FixedLenFeature([1], tf.int64),
'item': tf.FixedLenFeature([1], tf.int64),
'week': tf.FixedLenFeature([1], tf.int64),
'label': tf.FixedLenFeature([1], tf.int64),
'item_cont': tf.FixedLenFeature([6], tf.float32),
'item_cat': tf.FixedLenFeature([3092], tf.float32),
'user_cont': tf.FixedLenFeature([12], tf.float32),
'user_cat': tf.FixedLenFeature([3138], tf.float32)
}
)
user = features['user']
item = features['item']
week = features['week']
label = features['label']
item_cont = features['item_cont']
item_cat = features['item_cat']
user_cont = features['user_cont']
user_cat = features['user_cat']
return user, item, week, label, item_cont, item_cat, user_cont, user_cat
filename_queue = tf.train.string_input_producer(['201704_test.tfrecords'],
num_epochs=1)
user, item, week, label, item_cont, item_cat, user_cont, user_cat = \
read_and_decode(filename_queue=filename_queue)
item_cont_b = tf.train.batch([item_cont],
batch_size=3,
num_threads=1,
capacity=32,
enqueue_many=False,
shapes=None,
dynamic_pad=False,
allow_smaller_final_batch=True)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
for step in range(100000):
if coord.should_stop():
break
res = sess.run(item_cont_b)
print(res)
coord.request_stop()
coord.join(threads)
感谢任何有用的建议!