【发布时间】:2019-08-19 19:17:05
【问题描述】:
我是张量流的新手。 试过这个简单的例子:
import tensorflow as tf
sess = tf.Session()
x = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)
z = x + y
print(sess.run(z, feed_dict={x: 3.0, y: 4.5}))
得到了一些警告 The name tf.Session is deprecated. Please use tf.compat.v1.Session instead. 和正确答案 - 7.5
在阅读here 后,我了解到警告是由于从 tf 1.x 升级到 2.0 造成的,描述的步骤“简单”但没有给出任何示例......
我试过了:
@tf.function
def f1(x1, y1):
return tf.math.add(x1, y1)
print(f1(tf.constant(3.0), tf.constant(4.5)))
- 我的代码是否正确(在链接中定义的意义上)?
- 现在,我得到了
Tensor("PartitionedCall:0", shape=(), dtype=float32)作为输出,我怎样才能得到实际值?
【问题讨论】:
标签: python python-3.x tensorflow python-3.6