老师,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_size
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回答

会写代码的好厨师

2019-08-15

数据里面存放的元素的name是image和label么?这个要个打包的时候一致。

0
0

Python3+TensorFlow打造人脸识别智能小程序

理论与实战项目双管齐下,让AI技术真正落地应用,适合毕设展示。

1086 学习 · 538 问题

查看课程