数据解析遇到报错
来源:4-9 如何通过TF对已经打包过的数据进行解析

qq_Ken_cklBKS
2020-02-13
在对打包过的数据解析这一节,我按着老师课程的代码一个一个打,可最终报这个错,不明白怎么处理。
InvalidArgumentError (see above for traceback): DecodeRaw requires input strings to all be the same size, but element 1 has size 1373 != 1310
[[node DecodeRaw (defined at /home/ken/PycharmProjects/data_manager/reader_cifar10.py:25) ]]
[[node DecodeRaw (defined at /home/ken/PycharmProjects/data_manager/reader_cifar10.py:25) ]]
有上网搜索过但没找着解决方案,请老师指导,代码如下:
import tensorflow as tf
filelist = ['data/train.tfrecord']
file_queue = tf.train.string_input_producer(filelist,
num_epochs=None,
shuffle=True)
reader = tf.TFRecordReader()
_, ex = reader.read(file_queue)
feature = {
'image': tf.FixedLenFeature([], tf.string),
'label': tf.FixedLenFeature([], tf.int64)
}
batchsize = 2
batch = tf.train.shuffle_batch([ex],
batchsize,
capacity = batchsize*10,
min_after_dequeue = batchsize*5)
example = tf.parse_example(batch, features=feature)
image = example['image']
label = example['label']
image = tf.decode_raw(image, tf.uint8)
image = tf.reshape(image, [-1, 32, 32, 3])
with tf.Session() as sess:
sess.run(tf.local_variables_initializer())
tf.train.start_queue_runners(sess=sess)
for i in range(1):
image_bth, _ = sess.run([image, label])
import cv2
cv2.imshow("image", image_bth[0, ...])
cv2.waitKey(0)
写回答
1回答
-
看log,这个问题应该是图片尺寸没有对上,也就是图像编码成string和解码之后的尺寸不一致,我需要看一下你的打包数据的脚本。可以qq给我
032020-10-21
相似问题