python - 类型错误 : run() missing 1 required positional argument: 'fetches' on Session. 运行()

标签 python windows tensorflow

我是 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/

相关文章:

Python:从键:值对字符串创建嵌套字典

python - MongoDB 文档中的过滤器数组

windows - 如何使用批处理脚本最好通过 WINDOWS 中的端口 80 终止 CLOSE_WAIT 状态进程

Tensorflow 1.12 将 dataset.filter 应用于 dataset.window

python - 在 TensorFlow 中重命名已保存模型的变量范围

tensorflow - 在 keras 的 model.fit 中洗牌

Python:禁用 $HOME/.python-eggs?

python - 将列中的小数格式化为百分比

java - 特殊输入流,仅读取大小数组的倍数

c# - 为什么 "root\\StandardCimv2"在 Windows 7 中不起作用?