zoukankan      html  css  js  c++  java
  • caffe的网络层结构(1)

    1、concat层

    该层有两个相同作用的参数:

    message ConcatParameter {
      //指定拼接的维度,默认为1即以channel通道进行拼接;支持负索引,即-1表示最后一个维度
      optional int32 axis = 2 [default = 1];
    
      // 以后会被弃用,作用同axis一样,但不能指定为负数
      optional uint32 concat_dim = 1 [default = 1];
    }

    caffe中数据通常为4个维度,即 num×channels×height×width,因此默认值1表示channels通道进行拼接。

    • 选择axis=0,表示在num维度上进行拼接,可表示为:(k1+k2)*C*H*W;
    • 选择axis=1,表示在channel维度上进行拼接,可表示为:N*(k1+k2)*H*W。(对应于上面给出的4个维度)
    layer {
      name: "data_all"
      type: "Concat"
      bottom: "data_classfier"
      bottom: "data_boundingbox"
      bottom: "data_facialpoints"
      top: "data_all"
      concat_param {
        axis: 0
      }
    }

    除了拼接维度外的其它维度都必须相等。比如上面,输入图像均为 24×24×324×24×3,用于分类的有150张图片,用于boundingbox回归的有50张,用于关键点回归的也有50张,则最后拼接的结果就是 (150+50+50)×3×24×24
    2、Slice层

    与concat对应的是Slice层,来实现对数据集的拆分:

    message SliceParameter {
      // 下面两个指定沿哪个维度进行拆分,默认拆分channels通道
      optional int32 axis = 3 [default = 1];
      optional uint32 slice_dim = 1 [default = 1];
    
      // 指定拆分点
      repeated uint32 slice_point = 2;
    }

    此处将如上合并的数据集进行拆分:

    layer {
      name: "data_each"
      type: "Slice"
      bottom: "data_all"
      top: "data_classfier"
      top: "data_boundingbox"
      top: "data_facialpoints"
      slice_param {
        axis: 0
        slice_point: 150
        slice_point: 200
      }
    }

    其中slice_point的个数必须等于top的个数减一。输入的data_all维度为 250×3×24×24,拆分后的3个输出的维度依次为 150×3×24×24, 50×3×24×24, 50×3×24×24
    3、Eltwise层

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

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

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

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

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

    其中A和B的系数(coefficient)都要给出!



  • 相关阅读:
    php多态
    ssl certificate problem: self signed certificate in certificate chain
    test plugin
    open specific port on ubuntu
    junit vs testng
    jersey rest service
    toast master
    use curl to test java webservice
    update folder access
    elk
  • 原文地址:https://www.cnblogs.com/xiaochouk/p/10107726.html
Copyright © 2011-2022 走看看