gpt4 book ai didi

python-3.x - 属性错误 : module 'tensorflow' has no attribute 'Graph'

转载 作者:太空宇宙 更新时间:2023-11-03 16:55:14 27 4
gpt4 key购买 nike

我正在 Jupyter notebook 中编写以下代码。

import tensorflow as tf
g = tf.Graph()

我在执行这段简单的代码时遇到了以下错误。

AttributeError: module 'tensorflow' has no attribute 'Graph'

如果我从控制台执行相同的操作。有用。知道这里发生了什么。

更多信息:(测试是我的virtualenv)

ipython、jupyter、python版本:

(test) xingzhou@xingzhou008:~/tensorflow$ which ipython3
/home/xingzhou/tensorflow/test/bin/ipython3
(test) xingzhou@xingzhou008:~/tensorflow$ which jupyter
/home/xingzhou/tensorflow/test/bin/jupyter
(test) xingzhou@xingzhou008:~/tensorflow$ which python3
/home/xingzhou/tensorflow/test/bin/python3

从控制台执行:

(test) xingzhou@xingzhou008:~/tensorflow$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> g = tf.Graph()
>>> type(g)
<class 'tensorflow.python.framework.ops.Graph'>
>>>

最佳答案

确保您没有将任何 python 文件称为“tensorflow.py”

关于python-3.x - 属性错误 : module 'tensorflow' has no attribute 'Graph' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42340668/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com