在文档中, tf.while_loop 的主体需要是 python 可调用的。
i = tf.constant(0)
b = lambda i: tf.add(i,1)
c = lambda i: tf.less(i,10)
tf.while_loop(c,b, [i])
有效,但
def b(i):
tf.add(i,1)
i = tf.constant(0)
c = lambda i: tf.less(i,10)
tf.while_loop(c,b, [i])
抛出 ValueError: Attempt to convert a value (None) with an unsupported type() to a Tensor
在 2.0 中,eager execution 是默认的,我想知道这是什么问题?!