这两种功能fn1,并fn2可以返回多个张量,但他们必须返回的输出完全相同的数量和类型。
x = tf.constant(1.) bool = tf.constant(True) def fn1(): return tf.add(x, 1.), x def fn2(): return tf.add(x, 10.), x res1, res2 = tf.cond(bool, fn1, fn2) #tf.condreturns a list of two tensors # sess.run([res1, res2]) will return [2., 1.]