TensorFlow random_shuffle_queue is closed and has insufficient elements

后端 未结 6 1265
借酒劲吻你
借酒劲吻你 2020-12-15 05:00

I\'m reading batch of images by getting idea here from tfrecords(converted by this)

My images are cifar images, [32, 32, 3] and as you can see while reading and pas

6条回答
  •  囚心锁ツ
    2020-12-15 05:31

    You're likely processing the parsed TFRecord example wrong. E.g. trying to reshape a tensor to an incompatible size. You can debug using a tf_record_iterator to confirm the data you're reading is stored the way you think it is:

    import tensorflow as tf
    import numpy as np
    
    tfrecords_filename = '/path/to/some.tfrecord'
    record_iterator = tf.python_io.tf_record_iterator(path=tfrecords_filename)
    
    for string_record in record_iterator:
        # Parse the next example
        example = tf.train.Example()
        example.ParseFromString(string_record)
    
        # Get the features you stored (change to match your tfrecord writing code)
        height = int(example.features.feature['height']
                                     .int64_list
                                     .value[0])
    
        width = int(example.features.feature['width']
                                    .int64_list
                                    .value[0])
    
        img_string = (example.features.feature['image_raw']
                                      .bytes_list
                                      .value[0])
        # Convert to a numpy array (change dtype to the datatype you stored)
        img_1d = np.fromstring(img_string, dtype=np.float32)
        # Print the image shape; does it match your expectations?
        print(img_1d.shape)
    

提交回复
热议问题