在这里尝试通过 tensorflow教程;我用〜100个图像构建了一个tf记录文件,现在当我尝试以下操作时,内核挂起;为什么会这样?tf 记录文件并不大,只有 30MB+ 左右,读取它们应该不会花很长时间:
import tensorflow as tf
import os
print(os.path.exists("../carmakesorter/train-00000-of-00001"))
filenameQ = tf.train.string_input_producer(["../carmakesorter/train-00000-of-00001"],num_epochs=None)
# object to read records
recordReader = tf.TFRecordReader()
# read the full set of features for a single example
key, fullExample = recordReader.read(filenameQ)
# parse the full example into its' component features.
features = tf.parse_single_example(
fullExample,
features={
'image/height': tf.FixedLenFeature([], tf.int64),
'image/width': tf.FixedLenFeature([], tf.int64),
'image/colorspace': tf.FixedLenFeature([], dtype=tf.string,default_value=''),
'image/channels': tf.FixedLenFeature([], tf.int64),
'image/class/label': tf.FixedLenFeature([],tf.int64),
'image/class/text': tf.FixedLenFeature([], dtype=tf.string,default_value=''),
'image/format': tf.FixedLenFeature([], dtype=tf.string,default_value=''),
'image/filename': tf.FixedLenFeature([], dtype=tf.string,default_value=''),
'image/encoded': tf.FixedLenFeature([], dtype=tf.string, default_value='')
})
label = features['image/class/label']
with tf.Session() as sess:
print('start ...')
print(sess.run(label)) # I want to check the label here
print('end ...')
它打印:
True
start ...
我的笔记本内核已经挂了 10 分钟,我看不到会有结局。有人可以指出我做错了什么吗?