吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4423|回复: 6
收起左侧

[求助] module 'tensorflow' has no attribute 'compat'求助

[复制链接]
zgkjzf 发表于 2020-4-2 09:44
安装tensorflow2.1 一import tensorflow就报下面错误 怎么解决
2020-04-02 09:40:07.185822: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
Traceback (most recent call last):
  File "C:/Users/zaf/Desktop/jd/test2.py", line 1, in <module>
    import tensorflow
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\__init__.py", line 46, in <module>
    from . _api.v2 import compat
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py", line 39, in <module>
    from . import v1
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py", line 32, in <module>
    from . import compat
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\__init__.py", line 39, in <module>
    from . import v1
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\v1\__init__.py", line 29, in <module>
    from tensorflow._api.v2.compat.v1 import app
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\__init__.py", line 39, in <module>
    from . import v1
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\__init__.py", line 32, in <module>
    from . import compat
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\__init__.py", line 39, in <module>
    from . import v1
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_core\_api\v2\compat\v1\compat\v1\__init__.py", line 667, in <module>
    from tensorflow_estimator.python.estimator.api._v1 import estimator
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_estimator\__init__.py", line 10, in <module>
    from tensorflow_estimator._api.v1 import estimator
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\__init__.py", line 10, in <module>
    from tensorflow_estimator._api.v1.estimator import experimental
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_estimator\_api\v1\estimator\experimental\__init__.py", line 10, in <module>
    from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py", line 33, in <module>
    from tensorflow_estimator.python.estimator import estimator
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 53, in <module>
    from tensorflow_estimator.python.estimator import util as estimator_util
  File "C:\Program Files\Python\Python37\lib\site-packages\tensorflow_estimator\python\estimator\util.py", line 75, in <module>
    class _DatasetInitializerHook(tf.compat.v1.train.SessionRunHook):
AttributeError: module 'tensorflow' has no attribute 'compat'

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

luo青山 发表于 2020-4-2 10:27
你是用的TF2吧,这个一般是不兼容TF1.x的代码
luo青山 发表于 2020-4-2 10:29
tf2.x中丢弃了这个方法,所有报错,可以换TF版本回1.x,或者修改代码,怎么修改百度谷歌一下
Zhengyu123 发表于 2020-4-2 10:33
把import tensorflow as tf 改成 import tensorflow.compat.v1 as tf
如果还不行,建议卸载重装
 楼主| zgkjzf 发表于 2020-4-2 12:09
Zhengyu123 发表于 2020-4-2 10:33
把import tensorflow as tf 改成 import tensorflow.compat.v1 as tf
如果还不行,建议卸载重装

重装之后问题依旧
 楼主| zgkjzf 发表于 2020-4-2 12:11
luo青山 发表于 2020-4-2 10:29
tf2.x中丢弃了这个方法,所有报错,可以换TF版本回1.x,或者修改代码,怎么修改百度谷歌一下

现在问题是import tensorflow就报这个错,跟没按上似的,不是版本问题0
 楼主| zgkjzf 发表于 2020-4-2 12:20
安装gpu版本的tensorflow后不报错
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 18:46

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表