Caffe Prototxt 特殊层系列:Eltwise Layer

16 篇文章 4 订阅

Eltwise Layer是对多个bottom进行操作计算并将结果赋值给top,一般特点:多个输入一个输出,多个输入维度要求一致
首先看下Eltwise层的参数:

message EltwiseParameter {
  enum EltwiseOp {
    PROD = 0;       //点乘
    SUM = 1;        //加减(默认)
    MAX = 2;        //最大值
  }
  optional EltwiseOp operation = 1 [default = SUM];  // element-wise operation
  repeated float coeff = 2; // blob-wise coefficient for SUM operation

  // Whether to use an asymptotically slower (for >2 inputs) but stabler method
  // of computing the gradient for the PROD operation. (No effect for SUM op.)
  optional bool stable_prod_grad = 3 [default = true];
}

则Eltwise层的操作有三个:product(点乘), sum(相加减) 和 max(取大值),其中sum是默认操作。

假设输入bottom为A和B,
1)如果要实现element_wise的A+B,即A和B的对应元素相加,prototxt文件如下:

layer {
	  name: "eltwise_layer"
	  bottom: "A"
	  bottom: "B"
	  top: "diff"
	  type: "Eltwise"
	  eltwise_param {
	    operation: SUM
	  }
}​

2)如果实现A-B,则prototxt为:

layer {
	  name: "eltwise_layer"
	  bottom: "A"
	  bottom: "B"
	  top: "diff"
	  type: "Eltwise"
	  eltwise_param {
	    operation: SUM
	    coeff: 1
	    coeff: -1
	  }
}​

注意:其中A和B的系数(coefficient)都要给出。

3)如果实现A.*B,则prototxt为:

layer {
	  name: "eltwise_layer"
	  bottom: "A"
	  bottom: "B"
	  top: "diff"
	  type: "Eltwise"
	  eltwise_param {
	    operation: PROD
	  }
}​
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值