[Tensorflow小试]之tfRecord解码数据错误解决

在使用TensorFlow读取tfRecord文件时遇到OutOfRangeError,问题源于解码数据类型与原始数据类型不匹配。解决方案是确保解码类型(如tf.float32)与数据存储类型(如tf.float64)一致。不匹配会导致解码失败,返回空对象,进而引发错误。
摘要由CSDN通过智能技术生成
以下是读取.tfrecord数据的部分代码:

data_queue = tf.train.string_input_producer(image_list, shuffle=shuffle)
reader = tf.TFRecordReader()
fid, serialized_example = reader.read(data_queue)
parser = tf.parse_single_example(serialized_example, features=decomp_feature)

data_vol = tf.decode_raw(parser['data_vol'], tf.float32)
data_vol = tf.reshape(data_vol, raw_size)
data_vol = tf.slice(data_vol, [0, 0, 0], volume_size)

label_vol = tf.decode_raw(parser['label_vol'], tf.float32)
label_vol = tf.reshape(label_vol, raw_size)
label_vol = tf.slice(label_vol, [0, 0, 1], label_size)

在读取的过程中,总会报以下的错误:

OutOfRangeError (see above for traceback): RandomShuffleQueue '_3_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 8, current size 0)

根据网上大部分搜索的,可能是数据size和解码tfrecord打包的尺寸不匹配,或者是如下链接所述:

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值