Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python tensorflow首次运行问题_Python_Tensorflow_Python 3.6 - Fatal编程技术网

Python tensorflow首次运行问题

Python tensorflow首次运行问题,python,tensorflow,python-3.6,Python,Tensorflow,Python 3.6,我刚刚安装了tesorflow cpu,这是我的代码 import tensorflow as tf node1 = tf.constant(3.0) node2 = tf.constant(4.0) print(node1) 此操作未运行,出现以下错误: Traceback (most recent call last): File "c:\Python\Python36\cssi\final_project.py", line 1, in <module> impo

我刚刚安装了tesorflow cpu,这是我的代码

import tensorflow as tf
node1 = tf.constant(3.0)
node2 = tf.constant(4.0)
print(node1)
此操作未运行,出现以下错误:

Traceback (most recent call last):
  File "c:\Python\Python36\cssi\final_project.py", line 1, in <module>
    import tensorflow as tf
  File "c:\Python\Python36\cssi\tensorflow.py", line 2, in <module>
    node1 = tf.constant(3.0)
AttributeError: module 'tensorflow' has no attribute 'constant'
回溯(最近一次呼叫最后一次):
文件“c:\Python\Python36\cssi\final\u project.py”,第1行,在
导入tensorflow作为tf
文件“c:\Python\Python36\cssi\tensorflow.py”,第2行,在
节点1=tf.常数(3.0)
AttributeError:模块“tensorflow”没有属性“constant”

请帮助

重命名脚本即可。我在创建名为tensorflow.py的脚本时遇到了同样的问题。将其重命名为test.py,然后查看其工作原理

(base) D:\>python tensorflow.py
Traceback (most recent call last):
  File "tensorflow.py", line 1, in <module>
    import tensorflow as tf
  File "D:\tensorflow.py", line 2, in <module>
    node1 = tf.constant(3.0)
AttributeError: module 'tensorflow' has no attribute 'constant'

(base) D:\>python test.py
Tensor("Const:0", shape=(), dtype=float32)
(基本)D:\>python tensorflow.py
回溯(最近一次呼叫最后一次):
文件“tensorflow.py”,第1行,在
导入tensorflow作为tf
文件“D:\tensorflow.py”,第2行,在
节点1=tf.常数(3.0)
AttributeError:模块“tensorflow”没有属性“constant”
(基本)D:\>python test.py
张量(“常数:0”,形状=(),数据类型=浮点32)

您是如何安装tensorflow的?我按照他们网站上的教程进行了安装