我正在尝试执行这段代码:
import tensorflow as tf
x = tf.random_uniform([], minval=-1.0, maxval=1.0)
y = tf.random_uniform([], minval=-1.0, maxval=1.0)
default = lambda: tf.constant(0.0)
out = tf.case([(x < y, lambda: x + y), (x > y, lambda: x - y)], default)
with tf.Session() as sess:
print sess.run([x, y, default, out])
但是我收到了错误:
TypeError: Fetch argument <function <lambda> at 0x10de7bf50> has invalid type <type 'function'>, must be a string or Tensor. (Can not convert a function into a Tensor or Operation.)
我不确定这里应该是什么功能。