Extend中不兼容的GraphDef版本

时间:2016-03-02 23:02:22

标签: tensorflow

我有一些代码可以创建一个图形来处理一些图像,然后在循环中迭代sess.run()以获取形状[*,299,299,3]的批量图像张量。我想将这些图像提供给初始模型。

所以,我添加了一些代码来加载初始模型:

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 个答案:

答案 0 :(得分:1)

这很可能是因为使用太旧版本的TensorFlow来读入和运行图形 - 图形是使用较新版本的GraphDef创建的。尝试升级到0.7或HEAD,然后再次运行代码。