caffe 什么是 SetLossWeights?

caffe what is SetLossWeights?

我正在阅读 caffe 的 Layer 源代码,但遇到以下问题:

  1. Layer::SetLossWeights 函数在做什么?我知道在层 class 里面,有一个 loss_ 变量,它记录了:

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

他们有关系吗?

  1. 在 caffe.proto 文件中,LayerParameter loss_weight 仅用于损失层,对吗?

非常感谢。

  1. 损失权重的目的是合并来自多个层的损失。所以 Layer::SetLossWeights 将损失权重分配给 loss_ 变量和 diff blob ,它在 forward 中用于计算总损失。
  2. 因为带有后缀 loss 的默认层的损失权重为 1,而其他层的损失权重为 0。但是任何能够反向传播的层都可以被赋予非零值 loss_weight。

有关详细信息,请参阅 caffe loss tutorial

编辑:

Loss weight 只有在输入到另一层进行反向传播时才会改变,这不是作者的意图。正如他们在 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.

中对 Accuracy layer 所说的那样