老师,tf解析打包数据遇到个问题,麻烦看一下。 _, ex = reader.read(file_queue)返回的 _ 代表什么?
来源:4-9 如何通过TF对已经打包过的数据进行解析

baby猫
2019-08-05
代码如下:
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),
}
batch_size = 2
batch = tf.train.shuffle_batch([ex],
batch_size,
capacity=batch_size10,
min_after_dequeue=batch_size5)
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回答
-
会写代码的好厨师
2019-08-15
数据里面存放的元素的name是image和label么?这个要个打包的时候一致。
00
相似问题