Keras vertical ensemble model with condition in between
Just define your own model. I'm surprised your other models are outputting strings instead of numbers, but without more info this is about all I can give you, so I will assume the output of model A is a string.
import tensorflow as tfclass ModelC(tf.keras.Model): def __init__(self, A, B): super(ModelC, self).__init__() self.A = A self.B = B def call(self, inputs, training=False): x = self.A(inputs, training) if x == 'not-related': return x return self.B(inputs, training)