【问题标题】:tensorflow first run issuestensorflow 首次运行问题
【发布时间】:2018-07-23 00:35:02
【问题描述】:

我刚刚安装了 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'

请帮忙

【问题讨论】:

  • 你是如何安装 tensorflow 的?
  • 我跟着他们网站上的教程

标签: python tensorflow python-3.6


【解决方案1】:

只需重命名您的脚本。当我创建一个名为 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)

【讨论】:

    猜你喜欢
    • 2023-03-31
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多