【问题标题】:Tensorflow results have the following form <tf.Tensor 'Add:0' shape=() dtype=int32>Tensorflow 结果具有以下形式 <tf.Tensor 'Add:0' shape=() dtype=int32>
【发布时间】: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


    【解决方案1】:

    Tensorflow 是一个符号计算库,因此一旦调用“add”函数,就会得到一个符号变量,而不是最终输出。您必须使用会话运行它才能获得输出。在您的情况下,代码将是:

    sess = tf.InteractiveSession()
    c = tf.add(2,3)
    sess.run(c)
    

    查看TF Introduction了解更多详情

    【讨论】:

      猜你喜欢
      • 2021-09-13
      • 2019-06-15
      • 1970-01-01
      • 2021-04-05
      • 1970-01-01
      • 2020-12-28
      • 2021-10-17
      • 2020-11-16
      • 2020-08-06
      相关资源
      最近更新 更多