Код:
import tensorflow as tf
out = tf.constant([0, 1, 0])
ta = tf.constant([0, 1, 2])
crct = tf.constant(tf.math.logical_and(tf.equal(out, ta), tf.equal(out, 0)))
def f_crct_1(): return tf.add(out, ta) #in case crct is True
def f_crct_0(): return tf.square(out) #in case crct is False
res = tf.cond(crct , f_crct_1, f_crct_0)
#since crct = [ True, False, False]
#res = [0+0, 1**2, 0**2]
Я получаю: ValueError: Значение истинности массива с более чем одним элементом неоднозначно. Используйте a.any () или a.all ()
То, чего я хочу достичь, зависит от того, как crct запускает различные функции поэлементно. (Я новичок в tenorflow)