RandomShuffleQueue' _1_shuffle_batch / random_shuffle_queue'已关闭且元素不足(请求2,当前大小为0)

时间:2017-09-04 12:33:15

标签: python tensorflow-gpu

  

文件   " C:\用户\哈德\应用程序数据\本地\程序\的Python \ Python35 \ lib中\定点   packages_ tensorflow \ python \ framework \ ops.py",第2630行,在create_op中   original_op = self._default_original_op,op_def = op_def)文件   " C:\用户\哈德\应用程序数据\本地\程序\的Python \ Python35 \ lib中\定点   packages \ tensorflow \ python \ framework \ ops.py",第1204行, init   self._traceback = self._graph._extract_stack()#pylint:   disable = protected- access OutOfRangeError(参见上面的回溯):   RandomShuffleQueue' _1_shuffle_batch / random_shuffle_queue'关闭了   并且元素不足(请求2,当前大小为0)[[节点:   shuffle_batch = QueueDequeueManyV2 [component_types = [DT_UINT8,   DT_UINT8],timeout_ms = -1,   _device =" / job:localhost / replica:0 / task:0 / cpu:0"](shuffle_batch / random_shuffle_queue,shuffle_batch / n)]]

代码:

def read_and_decode(filename_queue, image_height=384, image_width=384, batch_size=2):
    reader = tf.TFRecordReader()
    _, serialized_data = reader.read(filename_queue)

    features = tf.parse_single_example(serialized_data, features={
        'height': tf.FixedLenFeature([], tf.int64),
        'width': tf.FixedLenFeature([], tf.int64),
        'image_raw_t': tf.FixedLenFeature([], tf.string),
        'image_raw_t+1': tf.FixedLenFeature([], tf.string),
    })
    img_t = tf.decode_raw(features['image_raw_t'], tf.uint8)
    img_t_ = tf.decode_raw(features['image_raw_t+1'], tf.uint8)
    height = tf.cast(features['height'], tf.int32)
    width = tf.cast(features['width'], tf.int32)

    image_shape = tf.stack([height, width, 3])

    img_t = tf.reshape(img_t, image_shape)
    img_t_ = tf.reshape(img_t_, image_shape)

    resized_img_t = tf.image.resize_image_with_crop_or_pad(image=img_t,

    target_height=image_height,

    target_width=image_width)
    resized_img_t_ = tf.image.resize_image_with_crop_or_pad(image=img_t_,

    target_height=image_height,

    target_width=image_width)

    _img_t, _img_t_ = tf.train.shuffle_batch([resized_img_t, resized_img_t_],
                                             batch_size=batch_size,
                                             capacity=10000, num_threads=2,
                                             min_after_dequeue=10)
    return _img_t, _img_t_



write_to_records(feature_list, tfrecords_filename=tfrecords_filename)

filename_queue = tf.train.string_input_producer(string_tensor=
[tfrecords_filename], num_epochs=1)
img_t, img_t_ = read_and_decode(filename_queue)

with tf.Session() as sess:
    sess.run(tf.local_variables_initializer())
    sess.run(tf.global_variables_initializer())

    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)

    for i in range(3):
        im1, im2 = sess.run([img_t, img_t_])

        print(im1[0, :, :, :].shape)
        print('Current Batch')

        plt.imshow(im1[0, :, :, :])
        plt.show()

        plt.imshow(im2[0, :, :, :])
        plt.show()

        plt.imshow(im1[1, :, :, :])
        plt.show()

        plt.imshow(im2[1, :, :, :])
        plt.show()

    coord.request_stop()
    coord.join(threads)

大家好,我正在尝试从tfrecords文件生成批处理,但在运行会话时我一直收到此错误。我使用Kitti跟踪数据集作为我的tfrecords文件。 有关问题可能是什么的任何建议? 我认为也许来自tfrecords文件的数据没有被正确读取,但到目前为止我找不到解决方案。 我在使用python 3.5的窗口上使用tensorflow-gpu

0 个答案:

没有答案