【问题标题】:Euclidean Loss Layer in CaffeCaffe 中的欧几里得损失层
【发布时间】:2015-09-14 22:41:36
【问题描述】:

我目前正在尝试在 caffe 中实现我自己的损失层,并且在尝试这样做时,我正在使用其他层作为参考。然而,令我困惑的一件事是top[0]->cpu_diff()Backward_cpu 中的使用。我将使用EuclideanLossLayer 作为参考。这是我的问题

  • 据我了解,top[0]->cpu_diff() 持有下一层的误差导数,但是如果没有其他层,它是如何初始化的呢?因为它在EuclideanLossLayer 中使用而没有执行任何检查:

    const Dtype alpha = sign * top[0]->cpu_diff()[0] / bottom[i]->num();
    
  • 同样,在EuclideanLossLayer 中,使用以下代码 sn-p 计算关于激活的误差的导数:

    const Dtype alpha = sign * top[0]->cpu_diff()[0] / bottom[i]->num();
    caffe_cpu_axpby(
      bottom[i]->count(),              // count
      alpha,                              // alpha
      diff_.cpu_data(),                   // a
      Dtype(0),                           // beta
      bottom[i]->mutable_cpu_diff());  // b
    

    如果我的第一个假设是正确的,并且top[0]->cpu_diff() 确实保留了上一层的误差导数,为什么我们只使用第一个元素,即top[0]->cpu_diff()[0],而不是乘以整个向量,即top[0]->cpu_diff()

【问题讨论】:

    标签: c++ deep-learning caffe


    【解决方案1】:

    对于损失层,没有下一层,因此 top diff blob 在技术上是未定义和未使用的 - 但 Caffe 使用这个预先分配的空间来存储不相关的数据:Caffe 支持将损失层与用户定义的权重相乘(loss_weight在 prototxt 中),此信息(单个标量浮点数)存储在顶部 blob 的 diff 数组的第一个元素中。这就是为什么您会在每个损失层中看到它们乘以该数量以支持该功能的原因。这在Caffe's tutorial about the loss layer 中有解释。

    这个权重通常用于给网络添加辅助损失。您可以在 Google 的 Going Deeper with ConvoltionsDeeply-Supervised Nets 中了解更多信息。

    【讨论】:

      猜你喜欢
      • 2018-07-30
      • 2018-11-20
      • 2013-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-15
      相关资源
      最近更新 更多