【问题标题】:AttributeError: module 'tensorflow.compat' has no attribute 'v1' Tensorflow v: 1.10.0AttributeError:模块“tensorflow.compat”没有属性“v1”Tensorflow v:1.10.0
【发布时间】:2020-01-29 22:45:02
【问题描述】:

我在尝试训练我的模型时遇到了这个错误:

(tensorflow1) C:\tensorflow1\models\research\object_detection>python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
Traceback (most recent call last):
  File "train.py", line 52, in <module>
    from object_detection.builders import model_builder
  File "C:\tensorflow1\models\research\object_detection\builders\model_builder.py", line 35, in <module>
    from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
  File "C:\tensorflow1\models\research\object_detection\models\faster_rcnn_inception_resnet_v2_feature_extractor.py", line 30, in <module>
    from nets import inception_resnet_v2
  File "C:\tensorflow1\models\research\slim\nets\inception_resnet_v2.py", line 375, in <module>
    batch_norm_updates_collections=tf.compat.v1.GraphKeys.UPDATE_OPS,
AttributeError: module 'tensorflow.compat' has no attribute 'v1'

张量流版本:1.10.0

我正在使用通过以下方式创建的 conda virtualenv:

conda create -n tensorflow1 pip python=3.5

(tensorflow1) conda install tensorflow-gpu

在 Windows 10 上工作

【问题讨论】:

  • 我也遇到了同样的问题...如果你知道了很想知道解决方案
  • @Dick 是我的tensorflow版本有问题,v1是tensorflow 2.0的,所以你得重写代码或者使用更早的版本
  • 谢谢...我一直在使用 tensorflow 1.9,因为这是我正在使用的教程。但是......看起来模型必须已经更新为使用 tensorflow 2...... Arg......我能找到的只有下降教程似乎是 1,并且事情正在升级到 2......有点尴尬的时间。将尝试降级模型。
  • @Dick 看看这个教程,它有一个视频,并且在 repo 中有所有特定版本,并从 Tensorflow repo 提交它使用。 github.com/EdjeElectronics/…
  • 遇到同样的问题,在 Ubuntu 18.04 上工作

标签: python tensorflow object-detection


【解决方案1】:

在此处(回答部分)提供解决方案,即使它出现在评论部分是为了社区的利益。

此代码tf.compat.v1.GraphKeys.UPDATE_OPS 不适用于Tensorflow==1.10.0

如果您使用的是旧版本的 TensorFlow,here 是一个表格,显示您应该使用哪个 GitHub 提交的存储库。

要将这些功能更新为1.152.2,如下所示

   conda install tensorflow=1.15

   conda install tensorflow=2.2

【讨论】:

    猜你喜欢
    • 2020-10-04
    • 2022-10-05
    • 2017-04-08
    • 2020-02-04
    • 2020-02-12
    • 2019-01-10
    • 2019-10-01
    • 2017-05-11
    • 2019-08-09
    相关资源
    最近更新 更多