If I define multiple loss layers in a network, will there be multiple back propagation happening from those ends to the beginning of the network? I mean, do they even work that way?
Suppose I have something like this:
Layer1{
}
Layer2{
}
...
Layer_n{
}
Layer_cls1{
bottom:layer_n
top:cls1
}
Layer_cls_loss1{
type:some_loss
bottom:cls1
top:loss1
}
Layer_n1{
bottom:layer_n
..
}
Layer_n2{
}
...
layer_n3{
}
Layer_cls2{
bottom:layer_n3
top:cls2
}
Layer_cls_loss2{
type:some_loss
bottom:cls2
top:loss2
}
layer_n4{
bottom:layer_n3
..
}
...
layer_cls3End{
top:cls_end
bottom:...
}
loss{
bottom:cls_end
top:loss:
type: someloss
}
So basically suppose instead of having one classification/loss per each network, we have several in between as well.
And in case they work, how could I add all the losses together and make my final loss the summation of all previous losses?
Caffe does this for you.
Furthermore, for each loss layer you have loss_weight
parameter that allows you to decide how influential this specific loss is with respect to all other losses in the net.
Overall, the loss minimized by caffe is the weighted sum of all loss layers in the model.
来源:https://stackoverflow.com/questions/42344012/how-can-i-have-multiple-losses-in-a-network-in-caffe