2017-03-17 205 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(),您缺少()

相關問題