caffe what is SetLossWeights?

一个人想着一个人 提交于 2019-12-12 23:47:19

问题


I am reading caffe's Layer source code but I got following questions:

  1. What is Layer::SetLossWeights function doing? I know that inside Layer class, there is a loss_ variable, which documents:

The vector that indicates whether each top blob has a non-zero weight in the objective function.

Do they have some relationships ?

  1. Inside the caffe.proto file, LayerParameter loss_weight is only for loss layers, is that correct?

Thanks very much.


回答1:


  1. The purpose of loss weight is to combine loss from multiple layers. So Layer::SetLossWeights is assigning the loss weight to loss_ variable and diff blob which is used in forward to compute total loss.
  2. As default layers with suffix loss have loss weight 1 and others with 0. But any layer that is able to backpropagate can be given a non-zero loss_weight.

For detail information see caffe loss tutorial.

Edit:

Loss weight will only change if it is input to another layer that does backprop which is not intended by the authors. As they said for Accuracy layer in this pull request it will break. The purpose of the diff in loss layer is to store loss weight not store gradient. For more detail you can see this discussion in caffe-users group.



来源:https://stackoverflow.com/questions/43094891/caffe-what-is-setlossweights

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!