AttributeError: 模块 'tensorflow.compat' 没有属性 'v1' Tensorflow v: 1.10.0 [英] AttributeError: module 'tensorflow.compat' has no attribute 'v1' Tensorflow v: 1.10.0

查看:248
本文介绍了AttributeError: 模块 'tensorflow.compat' 没有属性 'v1' Tensorflow v: 1.10.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试训练模型时遇到该错误:

I got that error when I'm trying to train my model:

(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'

TensorFlow 版本:1.10.0

Tensorflow version: 1.10.0

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

I'm using conda virtualenv created with:

conda create -n tensorflow1 pip python=3.5

(tensorflow1) conda install tensorflow-gpu

在 Windows 10 上工作

Working on Windows 10

推荐答案

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

Providing the solution here (Answer Section), even though it is present in the Comment Section for the benefit of the community.

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

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

If you are using an older version of TensorFlow, here is a table showing which GitHub commit of the repository you should use.

要将这些功能更新到 1.152.2 如下

To have those features update your version to 1.15 or 2.2 as below

   conda install tensorflow=1.15

   conda install tensorflow=2.2

这篇关于AttributeError: 模块 'tensorflow.compat' 没有属性 'v1' Tensorflow v: 1.10.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆