pyotrch--nn.Conv2d中groups参数的理解
调用形式:
self.conv2 = nn.Conv2d(expand_size, expand_size, kernel_size=kernel_size, stride=stride,
padding=kernel_size / 2, groups=expand_size, bias=False)
官方参数说明:
Args:
in_channels (int): Number of channels in the input image
out_channels (int): Number of channels produced by the convolution
kernel_size (int or tuple): Size of the convolving kernel
stride (int or tuple, optional): Stride of the convolution. Default: 1
padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0
padding_mode (string, optional). Accepted values `zeros` and `circular` Default: `zeros`
dilation (int or tuple, optional): Spacing between kernel elements. Default: 1
groups (int, optional): Number of blocked connections from input channels to output channels. Default: 1
bias (bool, optional): If ``True``, adds a learnable bias to the output. Default: ``True``
group这个参数是用做分组卷积的,但是现在用的比较多的是groups = in_channel,可以参考上面英文文档的最后一句。当groups = in_channel时,是在做的depth-wise conv的,具体思想可以参考MobileNet论文
缺点:参考shufflenet v2
凤舞九天