2017-03-17 208 views
3

我是tensorflow新手,我正在尝试遵循this入门教程。但“ex001.py”脚本内执行,该代码非常简单:TypeError:run()缺少1个必需的位置参数:'提取'Session.run()

import tensorflow as tf 

sess = tf.Session 
hello = tf.constant('Hello, TensorFlow!') 
print(hello) 
print(sess.run(hello)) 

我得到以下输出

Tensor("Const:0", shape=(), dtype=string) Traceback (most recent call last): File "C:\Users\Giuseppe\Desktop\ex001.py", line 6, in print(sess.run(hello)) TypeError: run() missing 1 required positional argument: 'fetches'

我已检查tf.Session.run()语法,但看起来正确的,我没有发现任何人有同样的问题。

我这个配置中运行:

  • Windows 7专业版SP1 64位
  • 的Python 3.5.3 64位
  • Tensorflow 1.0.1 CPU版本

谢谢提前

+0

不是'sess = tf.Session',它是'tf.Session()',你缺少'()' – xxi

+0

@xxi避免回答评论中的问题:)你应该做出答案。 – etarion

回答

7

不是sess = tf.Session,应该是tf.Session(),您缺少()

相关问题