# Joint Training and multiple losses in NetTrain

Jointly training a neural network to solve multiple tasks simultaneously sometimes results in elevated accuracy, and I'm looking for any known examples of this in Mathematica.

Here's the specific problem I'm trying to formulate into the NetGraph/NetTrain architecture: I have a set of facial images and three labels for each image: age (integer) and gender (binary) and race (7 classes).

Using Keras, training jointly on data with multiple labels per sample is straightforward using a base network with multiple final outputs and losses, e.g. cross entropy loss for race and mean absolute loss for age.

I'm not sure how to approach this in Mathematica, and any high level guidance would be appreciated, but specifically, how can one tell NetTrain to use different losses for different sublabel data?

• @M.R. you can use the third argument of NetTrain to attach specific weights and loss layers to specific output ports. See the "Details and Options" section of NetTrain for more info on that, but as an example, you could write e.g. {"AgeOut" -> MeanAbsoluteLossLayer[], "SexOut" -> CrossEntropyLossLayer["Indexed"] -> Scaled[5]}. – Taliesin Beynon Aug 16 '17 at 13:36