2016-03-02 59 views
0

我有一些代碼會創建一個圖形來處理一些圖像,然後在循環中迭代sess.run()以獲取形狀[*,299,299,3]的多批圖像張量。然後我想將這些圖像輸入到初始模型中。Extend中不兼容的GraphDef版本

所以,我添加了一些代碼來加載以來模型:

def create_graph(): 
    """"Creates a graph from saved GraphDef file and returns a saver.""" 
    # Creates graph from saved graph_def.pb. 
    print 'Loading graph...' 
    with tf.Session() as sess: 
     with gfile.FastGFile('/web/tensorflow_transfer/resources/classify_image_graph_def.pb', 'rb') as f: 
      graph_def = tf.GraphDef() 
      graph_def.ParseFromString(f.read()) 
      _ = tf.import_graph_def(graph_def, name='') 
    return sess.graph 

g = create_graph() 

for i in range(training_steps): 
    sess.run(...) 

現在即時得到這個錯誤運行run()時:

File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 368, in run 
    results = self._do_run(target_list, unique_fetch_targets, feed_dict_string) 
    File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 420, in _do_run 
    raise RuntimeError(compat.as_text(tf_session.TF_Message(status))) 
RuntimeError: Incompatible GraphDef versions in Extend: 1 != 0 

回答

1

這是最有可能使用太舊版本的TensorFlow讀入並運行圖形 - 圖形是使用GraphDef的新版本創建的。嘗試升級到0.7或HEAD,然後再次運行您的代碼。

+0

升級到0.7.1解決了這個問題。謝謝! – sthomps