我已经安装了tensorflow版本r0.11。

在我的文件名cartpole.py中,我导入了tensorflow:

 import tensorflow as tf

并使用它:
 tf.reset_default_graph()

尝试在PyCharm中运行我的项目时出现以下错误:
in <module>
tf.reset_default_graph()
AttributeError: module 'tensorflow' has no attribute 'reset_default_graph'

如何解决此错误?

最佳答案

通常,您可以通过以下方式导入tensorflow:

import tensorflow as tf

您可能已经在项目tensorflow.py中命名了一个文件,并且import语句正在从该文件中导入。

另外,您也可以尝试一下
from tensorflow.python.framework import ops
ops.reset_default_graph()

关于python - AttributeError : module 'tensorflow' has no attribute 'reset_default_graph' ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40782271/

10-09 07:27
查看更多