caffe 源码学习


Splitting

  • 类型(type):Split

Split layer用于将一个输入的blob分离成多个输出的blob。这用于当需要将一个blob输入至多个输出layer时。

Flattening

  • 类型(type):Flatten

Flatten layer用于把一个维度为n * c * h * w的输入转化为一个维度为 n * (c*h*w)的向量输出。

Concatenation

  • 类型(type):Concat(连结层)
  • CPU 实现: ./src/caffe/layers/concat_layer.cpp
  • CUDA、GPU实现: ./src/caffe/layers/concat_layer.cu
  • 参数 (concat_param):

    • 可选: 
      • axis [default 1]: 0 for concatenation along num and 1 for channels.(0代表连结num,1代表连结channel)
  • 输入(Input) 
    -n_i * c_i * h * w for each input blob i from 1 to K.(第i个blob的维度是n_i * c_i * h * w,共K个)

  • 输出(Output)

    • if axis = 0: (n_1 + n_2 + … + n_K) * c_1 * h * w, and all input c_i should be the same.(axis = 0时,输出 blob的维度为(n_1 + n_2 + … + n_K) * c_1 * h * w,要求所有的input的channel相同)
    • if axis = 1: n_1 * (c_1 + c_2 + … + c_K) * h * w, and all input n_i should be the same.(axis = 0时,输出 blob的维度为n_1 * (c_1 + c_2 + … + c_K) * h * w,要求所有的input的num相同)
  • 例子

layer {
  name: "concat"
  bottom: "in1"
  bottom: "in2"
  top: "out"
  type: "Concat"
  concat_param {
    axis: 1
  }
}
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

Concat layer用于把多个输入blob连结成一个输出blob。


Hinge / Margin

  • 类型(type):HingeLoss
  • CPU 实现: ./src/caffe/layers/hinge_loss_layer.cpp
  • CUDA、GPU实现: 尚无
  • 参数 (hinge_loss_param):

    • 可选: 
      • norm [default L1]: the norm used. Currently L1, L2(可以选择使用L1范数或者L2范数;默认为L1)
  • 输入(Input)

    • n * c * h * w Predictions(预测值)
    • n * 1 * 1 * 1 Labels(标签值)
  • 输出(Output)

    • 1 * 1 * 1 * 1 Computed Loss(计算得出的loss值)
  • 例子

# 使用L1范数
layer {
  name: "loss"                  # 名称:loss
  type: "HingeLoss"             # 类型:HingeLoss
  bottom: "pred"                # 输入:预测值
  bottom: "label"               # 输入:标签值
}

# 使用L2范数
layer {
  name: "loss"                  # 名称:loss
  type: "HingeLoss"             # 类型:HingeLoss
  bottom: "pred"                # 输入:预测值
  bottom: "label"               # 输入:标签值
  top: "loss"                   # 输出:loss值
  hinge_loss_param {
    norm: L2                    # 使用L2范数
  }
}
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 关于范数: 
    范数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值