2017-09-14 65 views
0

試圖在這裏通過張量流tutorial;我用〜100個圖像構建一個tf記錄文件,現在當我嘗試以下操作時,內核會掛起;這是爲什麼發生?課題組記錄文件不是很大隻有30MB +左右,它不應該採取長期在閱讀他們:讀取TF記錄文件需要很長時間

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分鐘,已經和我看不到會有結局。有人能指出我做錯了什麼嗎?

回答

2

你忘了用'tf.train.start_queue_runners(sess)'運行隊列跑步者'