【发布时间】:2016-10-14 15:27:37
【问题描述】:
安装 Tensorflow 后,例如,当我尝试使用 tf.add(2,3) 添加数字时,它只返回 tf.Tensor 'Add:0' shape=() dtype=int32 而不是结果。我在 64 位 Linux 上安装了带有 Anaconda 的 Tensorflow。我怎样才能得到结果(例如 5)?
【问题讨论】:
标签: linux installation tensorflow anaconda
安装 Tensorflow 后,例如,当我尝试使用 tf.add(2,3) 添加数字时,它只返回 tf.Tensor 'Add:0' shape=() dtype=int32 而不是结果。我在 64 位 Linux 上安装了带有 Anaconda 的 Tensorflow。我怎样才能得到结果(例如 5)?
【问题讨论】:
标签: linux installation tensorflow anaconda
Tensorflow 是一个符号计算库,因此一旦调用“add”函数,就会得到一个符号变量,而不是最终输出。您必须使用会话运行它才能获得输出。在您的情况下,代码将是:
sess = tf.InteractiveSession()
c = tf.add(2,3)
sess.run(c)
查看TF Introduction了解更多详情
【讨论】: