【问题标题】:L2 normalization in Caffe using already existing layers使用现有层在 Caffe 中进行 L2 归一化
【发布时间】:2016-07-22 01:09:31
【问题描述】:

我正在尝试在 Caffe 中为图层执行 L2 标准化。这个想法有点像 http://www.cs.cornell.edu/~kb/publications/SIG15ProductNet.pdf 这样的对比损失中使用这些 L2 归一化 fc7 特征。

我可以找到一些链接,人们在那里发布了 L2 规范化层的代码。但是我想知道是否可以使用 Caffe 的本地响应规范化层或其他任何方法。

我有一个 1x2048 的最终 fc 向量(2048 个大小为 1x1 的通道)。有人可以指导我吗?

【问题讨论】:

  • L2 标准化已经可以在 Caffe 中完成,例如见github.com/BVLC/caffe/issues/1224;不清楚你对 LRN 的意思,但我看不出为什么不能使用 Caffe 来实现它。
  • @bjou 实际上它还没有出现在 Caffe 源中。我可以使用github.com/happynear/caffe-windows/blob/master/src/caffe/layers/… 并重新构建,但不确定。
  • 在当前的Caffe master中确实没有单独的layer,但是还是可以的。同样,请参阅此 github.com/BVLC/caffe/issues/1224#issuecomment-147113995(包括代码示例)。如果您不想使用您引用的分支,您甚至可以将该函数包装为 PythonLayer,以便在 Caffe 中更轻松地使用。
  • 是的,但我不确定如何使用该 python 代码来训练网络。所以可能我会使用该层并重新编译。

标签: computer-vision normalization deep-learning caffe


【解决方案1】:

您可以使用简单层的组合在 Caffe 中执行 L2 归一化:

layer {
  name: "denom"
  type: "Reduction"
  bottom: "loss"
  top: "denom"
  reduction_param {
    operation: SUMSQ
    axis: 1
  }
}
layer {
  name: "power"
  type: "Power"
  bottom: "denom"
  top: "power"
  power_param {
    power: -0.5
    shift: 9.99999996004e-13
  }
}
layer {
  name: "reshape"
  type: "Reshape"
  bottom: "power"
  top: "reshape"
  reshape_param {
    shape {
      dim: 1
    }
    axis: -1
    num_axes: 0
  }
}
layer {
  name: "tile"
  type: "Tile"
  bottom: "reshape"
  top: "tile"
  tile_param {
    axis: 1
    tiles: 300
  }
}
layer {
  name: "elwise"
  type: "Eltwise"
  bottom: "loss"
  bottom: "tile"
  top: "elwise"
  eltwise_param {
    operation: PROD
  }
}

【讨论】:

    猜你喜欢
    • 2017-05-10
    • 2017-05-25
    • 2016-07-25
    • 2017-07-14
    • 2017-04-19
    • 2020-04-23
    • 2016-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多