【err】tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue
problem
Traceback (most recent call last): File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call return fn(*args) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_0_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 10, current size 0) [[{{node shuffle_batch}}]] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "test_TFRecord.py", line 46, in <module> print(sess.run(label_batch)) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1173, in _run feed_dict_tensor, options, run_metadata) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run run_metadata) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_0_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 10, current size 0) [[node shuffle_batch (defined at test_TFRecord.py:34) ]] Original stack trace for 'shuffle_batch': File "test_TFRecord.py", line 34, in <module> num_threads=7) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func return func(*args, **kwargs) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/training/input.py", line 1348, in shuffle_batch name=name) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/training/input.py", line 875, in _shuffle_batch dequeued = queue.dequeue_many(batch_size, name=name) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/ops/data_flow_ops.py", line 488, in dequeue_many self._queue_ref, n=n, component_types=self._dtypes, name=name) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 3862, in queue_dequeue_many_v2 timeout_ms=timeout_ms, name=name) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func return func(*args, **kwargs) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op op_def=op_def) File "/home/xxx/anaconda3/envs/mtcnn_tfgpu/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 2005, in __init__ self._traceback = tf_stack.extract_stack()
code

# -*- coding: utf-8 -*- """ @author: friedhelm """ import tensorflow as tf img_size = 12 filename_queue = tf.train.string_input_producer(["/home/xxx/workspace/test_code/github_test/MTCNN-tensorflow/version_1_0/DATA/12/neg_12_train.tfrecords"],shuffle=True,num_epochs=10) reader = tf.TFRecordReader() _, serialized_example = reader.read(filename_queue) #返回文件名和文件 features = tf.parse_single_example(serialized_example, features={ 'img':tf.FixedLenFeature([],tf.string), 'label':tf.FixedLenFeature([],tf.int64), 'roi':tf.FixedLenFeature([4],tf.float32), 'landmark':tf.FixedLenFeature([10],tf.float32), }) img=tf.decode_raw(features['img'],tf.uint8) label=tf.cast(features['label'],tf.int64) roi=tf.cast(features['roi'],tf.float32) landmark=tf.cast(features['landmark'],tf.float32) # img = tf.reshape(img, [48,48,3]) img = tf.reshape(img, [img_size,img_size,3]) # img=img_preprocess(img) min_after_dequeue = 1000 # 10000 batch_size = 10 # 64 capacity = min_after_dequeue + 10 * batch_size image_batch, label_batch, roi_batch, landmark_batch = tf.train.shuffle_batch([img,label,roi,landmark], batch_size=batch_size, capacity=capacity, min_after_dequeue=min_after_dequeue, num_threads=7) i=0 with tf.Session() as sess: sess.run((tf.global_variables_initializer(), tf.local_variables_initializer())) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(sess=sess,coord=coord) while(1): i=i+1 if(i%9==1): print(sess.run(label_batch))
why?
解决方法:详见here;
完
各美其美,美美与共,不和他人作比较,不对他人有期待,不批判他人,不钻牛角尖。
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
心正意诚,做自己该做的事情,做自己喜欢做的事情,安静做一枚有思想的技术媛。
版权声明,转载请注明出处:https://www.cnblogs.com/happyamyhope/
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
2018-10-08 【图像处理】快速计算积分图
2018-10-08 【图像处理】Haar-like特征