# Training a neural network with TWO possible correct outputs for one input

I have a system as a black box that has two correct outputs for a single input sample. now I want to train a neural network to generate at least one of the correct outputs for that input sample. what should I do 🤷🏻‍♂️

• You could try and calculate the loss by comparing the model's output to both labels and use the lowest loss of the two to backpropagate through the network. Apr 17 at 20:11

With Keras, you could use the functional API, to estimate a model with two outputs („multioutput“). Simply train the model on two outputs like:

# Outputs
out1 = Dense(1)(x)
out2 = Dense(1)(x)

# Compile/fit the model
model = Model(inputs=Input_1, outputs=[out1,out2])
model.compile(optimizer = "rmsprop", loss = 'mse')

# Add actual data here in the fit statement
model.fit(train_data, [train_targets,train_targets2], epochs=500, batch_size=4, verbose=0, validation_split=0.2)


Find the full model here: https://github.com/Bixi81/Python-ml/blob/master/keras_multitarget_functionalAPI.py

• I cannot separate the two outputs. Each time I put the input on my Black Box model, one output is generated and for each input, a maximum of two outputs are generated. This black box has two separate systems inside, each of which randomly selects one of them, but Both are true. I want my model to eventually learn the behavior of one of these systems and converge on it, but I do not know what each output produced is. Apr 18 at 13:14