2016-08-12 49 views
0

我想在最開始的IM在tensorflowTensorFlow多線程StatusNotOK

實現解耦隊列訓練initilizing圖

def init(self,restore,network_name): 


    self.sess = tf.InteractiveSession() 
    (some other stuff) 

    self.data_a = tf.placeholder(tf.float32, [1,9]) 
    self.data_b = tf.placeholder(tf.int8, [1, 162]) 
    self.q = tf.FIFOQueue(capacity=100000, 
     dtypes=[tf.float32, tf.int8], 
     shapes=[[1,9], [1,162]] 
    ) 
    self.enqueue_op = self.q.enqueue([self.data_a, 
             self.data_b]) 
    self.sess.run(tf.initialize_all_variables()) 

在主程序中我有兩個線程。

第一個排隊,由我的主要程序生成新的數據:

def load_and_enqueue(self, observations): 
     _data_a = [d[0] for d in observations] 
     _data_b = [d[1] for d in observations] 

     self.sess.run(self.enqueue_op, feed_dict={self.data_a: _data_a, 
                self.data_b:_data_b}) 

訓練功能被另一個線程或MainProgram(主程序)稱這並不重要,因爲它產生了同樣的錯誤

def train(self): 

     tensor_a,tensor_b= self.q.dequeue_many(200) 

     data_a,data_b= self.sess.run([tensor_a,tensor_b])   
     # do something meaningful 

過了一段時間它發生,如果self.sess.run([tensor_a,tensor_b])被稱爲我得到以下錯誤

return tf_session.TF_Run(session, feed_dict, fetch_list, target_list) 
tensorflow.python.pywrap_tensorflow.StatusNotOK: Not found: FetchOutputs node FIFOQueue_DequeueMany_39:0: not found 

我認爲這是某種競爭條件,但我現在不知道如何解決它。任何幫助將是非常好的

回答