如何在Caffe中的网络中造成多个损失? [英] How can I have multiple losses in a network in Caffe?

查看:97
本文介绍了如何在Caffe中的网络中造成多个损失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在网络中定义了多个损耗层,那么从网络的两端到网络的起始端会发生多个反向传播吗?我的意思是,它们甚至可以那样工作吗?

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?

假设我有这样的东西:

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为您做到了。

此外,对于每个损失层,您都有 loss_weight 参数,可让您确定此特定损失相对于网中所有其他损失的影响力。

总体而言,通过caffe最小化的损失为加权模型中所有损耗层的总和。

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.

这篇关于如何在Caffe中的网络中造成多个损失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆