Caffe入门:mobilenet_V1的Caffe实现—卷积参数group的使用

问题:mobilenetV1是基于tensorflow实现的,现在我需要将depthwise separable convolution利用Caffe实现,应该怎么办呢?
解决方法:使用卷积参数group实现。
       group对输入输出对应分组,默认为1,也就是说默认输出输入的所有通道各为一组。输出一个通道由输入所有通道进行卷积运算。如果我们把卷积group等于输入通道,输出通道等于输入通道便轻松实现了depthwize separable convolution结构。
如下,便是一个depthwize sepatable convolution示例:

layer {
  name: "conv2_1"
  type: "Convolution"
  bottom: "pool1b"
  top: "conv2_1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 64
    kernel_size: 3
    stride: 1
    pad: 1
    group: 64
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "relu2_1"
  type: "PReLU"
  bottom: "conv2_1"
  top: "conv2_1"
}
layer {
  name: "conv2_1_1"
  type: "Convolution"
  bottom: "conv2_1"
  top: "conv2_1_1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  convolution_param {
    num_output: 64
    kernel_size: 1
    stride: 1
    pad: 0
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "relu2_1_1"
  type: "PReLU"
  bottom: "conv2_1_1"
  top: "conv2_1_1"
}

备注:group参数理解:https://blog.csdn.net/duan19920101/article/details/102615917

发布了185 篇原创文章 · 获赞 873 · 访问量 127万+

猜你喜欢

转载自blog.csdn.net/duan19920101/article/details/102618913
今日推荐