чтение из файла tfrecord - PullRequest
0 голосов
/ 09 мая 2018

Я пытаюсь прочитать данные изображения из файла tfrecord. Мой код для записи в файл записи tf закодированного изображения выглядит так:

def create_tf_example(example):
   height = 256
   width =  256
   depth =3
   filename = example['Title']
   filename = filename.encode()
   path = example['path']
   path  = path .replace('.json','')
   example['path'] = path
   with open(example['path'],'rb') as f:  #encoding the image
        encoded_image_data = f.read()

И когда я пытаюсь прочитать закодированное изображение:

def read_and_decode (filename_queue):

    reader = tf.TFRecordReader()

    _, serialized_example = reader.read(filename_queue)


    features = tf.parse_single_example(
         serialized_example,

         features={
         'image/height' : tf.FixedLenFeature([], tf.int64),
         'image/width'  : tf.FixedLenFeature([],tf.int64),
         'image/depth'  : tf.FixedLenFeature([], tf.int64),
         'image/encoded': tf.FixedLenFeature([], tf.string),

        })

     image = tf.decode_raw(features['image/encoded'], tf.uint8)

     height = tf.cast(features['image/height'], tf.int64)
     width = tf.cast(features['image/width'], tf.int64)
     depth = tf.cast(features['image/depth'], tf.int64)



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

     image = tf.reshape(image, image_shape)



     images = image

     return images

Это дает мне ошибку:

    InvalidArgumentError (see above for traceback): Input to reshape is a     tensor with 11566 values, but the requested shape has 196608
   [[Node: Reshape = Reshape[T=DT_UINT8, Tshape=DT_INT64, _device="/job:localhost/replica:0/task:0/device:CPU:0"](DecodeRaw, stack)]]

Мне кажется, что когда я кодирую, он не в состоянии кодировать все 3 канала в изображении. Пожалуйста, помогите

...