Train无法输出训练的中间值

来源:5-5 Train部分代码编写

qq_Ken_cklBKS

2020-02-17

老师,我按照课程敲的代码,在执行时报出如下错误,根据报错追溯到文件的代码,反复跟课程的代码比对,没发现异样,请您指导。
我已在QQ上将工程文件打包发过去了,请查看,谢谢!

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1334, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1319, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1407, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 64, current size 2)
	 [[{{node shuffle_batch}}]]
	 [[{{node DecodeRaw}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ken/PycharmProjects/cifar10/train.py", line 137, in <module>
    train()
  File "/home/ken/PycharmProjects/cifar10/train.py", line 109, in train
    sess.run([tr_im, tr_label])
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 929, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1152, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1328, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1348, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 64, current size 2)
	 [[node shuffle_batch (defined at /home/ken/PycharmProjects/cifar10/readcifar10.py:17) ]]
	 [[node DecodeRaw (defined at /home/ken/PycharmProjects/cifar10/readcifar10.py:26) ]]

Caused by op 'shuffle_batch', defined at:
  File "/home/ken/PycharmProjects/cifar10/train.py", line 137, in <module>
    train()
  File "/home/ken/PycharmProjects/cifar10/train.py", line 71, in train
    tr_im, tr_label = readcifar10.read(batchsize, 0, 1)
  File "/home/ken/PycharmProjects/cifar10/readcifar10.py", line 17, in read
    min_after_dequeue=batchsize * 5)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/input.py", line 1346, in shuffle_batch
    name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/input.py", line 873, in _shuffle_batch
    dequeued = queue.dequeue_many(batch_size, name=name)
  File "/usr/local/lib/python3.6/dist-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 "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_data_flow_ops.py", line 3645, in queue_dequeue_many_v2
    timeout_ms=timeout_ms, name=name)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
    op_def=op_def)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
    op_def=op_def)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1801, in __init__
    self._traceback = tf_stack.extract_stack()

OutOfRangeError (see above for traceback): RandomShuffleQueue '_1_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 64, current size 2)
	 [[node shuffle_batch (defined at /home/ken/PycharmProjects/cifar10/readcifar10.py:17) ]]
	 [[node DecodeRaw (defined at /home/ken/PycharmProjects/cifar10/readcifar10.py:26) ]]


Process finished with exit code 1

写回答

2回答

会写代码的好厨师

2020-02-24

数据读取中的random-shuffle出了问题,可以吧代码发给我。我来调试一下。

1
1
qq_白玉_1
老师有这个问题的结果了吗,同样的错误
2020-07-03
共1条回复

qq_白玉_1

2020-07-03

同学,有这个问题的结果了吗,同样的报错

0
0

Python3+TensorFlow打造人脸识别智能小程序

理论与实战项目双管齐下,让AI技术真正落地应用,适合毕设展示。

1086 学习 · 538 问题

查看课程