我已经在 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'
没有找到与此相关的帖子。有人可以帮忙吗?
小智 12
sess=tf.compat.v1.InteractiveSession()
sess = tf.InteractiveSession()如果您使用的是 tesorflow 2.0.0 版本,请使用上面的行而不是行
错误由 Tensorflow 版本引起。当您安装 v2.x 并尝试使用 v1.x 时,您将收到此错误。为了避免这种情况,
import tensorflow as tf
import tensorflow.compat.v1 as tfc
当您在其他函数上遇到相同的错误时,请使用tfc而不是tf:
sess = tfc.InteractiveSession()
my_tensor = tfc.random_uniform((4, 4), 0, 1)
print(my_tensor)
| 归档时间: | 
 | 
| 查看次数: | 28792 次 | 
| 最近记录: |