什么是 'tensorflow' has no attribute 'GraphDef' with Tensorflow version 2.0.0?
What is 'tensorflow' has no attribute 'GraphDef' with Tensorflow version 2.0.0?
我在我正在开发的对象检测应用程序的一部分中使用了以下功能
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
当我 运行 此代码时,出现以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-6-d55b98fd5a78> in <module>
1 detection_graph = tf.Graph()
2 with detection_graph.as_default():
----> 3 od_graph_def = tf.GraphDef()
4 with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
5 serialized_graph = fid.read()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'
我正在使用 TensorFlow 2.0.0。这与版本不匹配有关吗?
此代码来自以下link.
是的,这是一个版本不匹配的问题,你不应该盲目地认为每个库都支持最近才发布的 TensorFlow 2.0。
如果一个库没有公布对 TensorFlow 2.0 的明确支持,那么您应该将它与 TensorFlow 一起使用 1.x
确保您已正确安装 link、
中给出的库
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md
我在我正在开发的对象检测应用程序的一部分中使用了以下功能
detection_graph = tf.Graph()
with detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
当我 运行 此代码时,出现以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-6-d55b98fd5a78> in <module>
1 detection_graph = tf.Graph()
2 with detection_graph.as_default():
----> 3 od_graph_def = tf.GraphDef()
4 with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:
5 serialized_graph = fid.read()
AttributeError: module 'tensorflow' has no attribute 'GraphDef'
我正在使用 TensorFlow 2.0.0。这与版本不匹配有关吗?
此代码来自以下link.
是的,这是一个版本不匹配的问题,你不应该盲目地认为每个库都支持最近才发布的 TensorFlow 2.0。
如果一个库没有公布对 TensorFlow 2.0 的明确支持,那么您应该将它与 TensorFlow 一起使用 1.x
确保您已正确安装 link、
中给出的库https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md