原文地址:https://blog.csdn.net/liyuan123zhouhui/article/details/70858472
caffe Convolution层的convolution_param参数字典中有一个group参数,其意思是将对应的输入通道与输出通道数进行分组,比如输入数据大小为
90x100x100x32 90是数据批大小 100x100是图像数据shape,32是通道数,要经过一个3x3x48的卷积,group默认是1,就是全连接的卷积层,
如果group是2,那么对应要将输入的32个通道分成2个16的通道,将输出的48个通道分成2个24的通道。对输出的2个24的通道,第一个24通道与输入的第一个16通道进行全卷积,第二个24通道与输入的第二个16通道进行全卷积。极端情况下,输入输出通道数相同,比如为24,group大小也为24,那么每个输出卷积核,只与输入的对应的通道进行卷积。
caffe官网原话是:
group (g) [default 1]: If g > 1, we restrict the connectivity of each filter to a subset of the input. Specifically, the input and output channels are separated into g groups, and the i-th output group channels will be only connected to the i-th input group channels.
---------------------
原文地址:https://blog.csdn.net/a200800170331/article/details/80440494
问题: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"
}
caffe官网说明:
---------------------
作者:蝴蝶也可以飞过沧海
来源:CSDN
原文:https://blog.csdn.net/a200800170331/article/details/80440494
版权声明:本文为博主原创文章,转载请附上博文链接!