AttributeError: module 'tensorflow.compat' has no attribute 'v1' Tensorflow v: 1.10.0

AttributeError: module 'tensorflow.compat' has no attribute 'v1' Tensorflow v: 1.10.0

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

(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

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

此代码 tf.compat.v1.GraphKeys.UPDATE_OPSTensorflow==1.10.0

上不可用

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

要获得这些功能,请将您的版本更新为 1.152.2,如下所示

   conda install tensorflow=1.15

   conda install tensorflow=2.2