我是 tensorflow 的新手,我正在尝试关注 this入门教程。但是在“ex001.py”脚本中执行这个非常简单的代码:
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 Professional sp1 64 位
- Python 3.5.3 64 位
- Tensorflow 1.0.1 cpu版本
提前致谢
最佳答案
不是sess = tf.Session
,应该是tf.Session()
,你漏了()
关于python - 类型错误 : run() missing 1 required positional argument: 'fetches' on Session. 运行(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42858114/