Skip to main content
 首页 » 编程设计

python之属性错误 : module 'tensorflow' has no attribute 'InteractiveSession'

2024年10月17日30mengfanrong

我已经在 Ubuntu 16.10 环境中安装了来自 Source 的 tensorflow。一切顺利,但现在在编译程序时,它显示以下错误:

Traceback (most recent call last): 
  File "ff.py", line 3, in <module> 
    sess = tf.InteractiveSession() 
AttributeError: module 'tensorflow' has no attribute 'InteractiveSession' 

没有找到与此相关的任何帖子。有人可以帮忙吗?

请您参考如下方法:

sess=tf.compat.v1.InteractiveSession() 

如果您使用的是 tesorflow 2.0.0 版本,请使用上面的行而不是 sess = tf.InteractiveSession() 行