Wie füge ich eine if-Bedingung in ein TensorFlow-Diagramm ein?

Sagen wir, ich habe folgenden Code:

x = tf.placeholder("float32", shape=[None, ins_size**2*3], name = "x_input")
condition = tf.placeholder("int32", shape=[1, 1], name = "condition")
W = tf.Variable(tf.zeros([ins_size**2*3,label_option]), name = "weights")
b = tf.Variable(tf.zeros([label_option]), name = "bias")

if condition > 0:
    y = tf.nn.softmax(tf.matmul(x, W) + b)
else:
    y = tf.nn.softmax(tf.matmul(x, W) - b)  

ürde dasif Statement Arbeit in der Berechnung (glaube ich nicht)? Wenn nicht, wie kann ich ein @ hinzufügeif Anweisung in das TensorFlow-Berechnungsdiagramm?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage