【问题标题】:What is 'tensorflow' has no attribute 'GraphDef' with Tensorflow version 2.0.0?什么是 Tensorflow 版本 2.0.0 中没有属性“GraphDef”的“tensorflow”?
【发布时间】:2019-10-05 14:16:32
【问题描述】:

我正在开发的部分对象检测应用程序中使用以下功能

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 machine-learning object-detection


    【解决方案1】:

    是的,这是版本不匹配的问题,不要盲目假设每个库都支持最近才发布的 TensorFlow 2.0。

    如果一个库没有宣传对 TensorFlow 2.0 的明确支持,那么您应该将它与 TensorFlow 1.x 一起使用

    【讨论】:

      【解决方案2】:

      确保您已正确安装链接中给出的库,

      https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md
      

      【讨论】:

        猜你喜欢
        • 2020-02-04
        • 2020-05-06
        • 1970-01-01
        • 1970-01-01
        • 2020-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-14
        相关资源
        最近更新 更多