going beyond the sequential modelthe keras functional api age income gender dense dense dense convnet social media posts figure social media model with hree heads importantlytraining such model requires the ability to specify different loss functions for different heads of the networkfor instanceage prediction is scalar regression taskbut gender prediction is binary classification taskrequiring different training procedure but because gradient descent requires you to minimize scalaryou must combine these losses into single value in order to train the model the simplest way to combine different losses is to sum them all in kerasyou can use either list or dictionary of losses in compile to specify different objects for different outputsthe resulting loss values are summed into global losswhich is minimized during training listing compilat ion opt ions of mult -out put modelmult iple losses model compile(optimizer='rmsprop'loss=['mse''categorical_crossentropy''binary_crossentropy']model compile(optimizer='rmsprop'loss={'age''mse''income''categorical_crossentropy''gender''binary_crossentropy'}equivalent (possible only if you give names to the output layersnote that very imbalanced loss contributions will cause the model representations to be optimized preferentially for the task with the largest individual lossat the expense of the other tasks to remedy thisyou can assign different levels of importance to the loss values in their contribution to the final loss this is useful in particular if the lossesvalues use different scales for instancethe mean squared error (mseloss used for the age-regression task typically takes value around - whereas the crossentropy loss used for the gender-classification task can be as low as in such situationto balance the contribution of the different lossesyou can assign weight of to the crossentropy loss and weight of to the mse loss listing compilat ion opt ions of mult -out put modelloss weighting model compile(optimizer='rmsprop'loss=['mse''categorical_crossentropy''binary_crossentropy']loss_weights=[ ]licensed to