iduta / pyconv

Pyramidal Convolution: Rethinking Convolutional Neural Networks for Visual Recognition (https://arxiv.org/pdf/2006.11538.pdf)
MIT License
328 stars 53 forks source link

pyconv #6

Closed czy112 closed 4 years ago

czy112 commented 4 years ago

can you tell me how to use this pyconv in shufflenetv2 blocks?thanks

dw

when i use this PyConv2(oup_inc, oup_inc, pyconv_kernels=[3,5],stride=stride,pyconv_groups=[1,4]), to replace nn.Conv2d(oup_inc, oup_inc, 3, stride, 1, groups=oup_inc, bias=False),

error is raise ValueError('in_channels must be divisible by groups') ValueError: in_channels must be divisible by groups

can you tell me the reason?

iduta commented 4 years ago

The reason is one of the grouped convolution requirements: the number of input feature maps must be divisible by the number of groups. We shortly addressed this aspect in our paper (https://arxiv.org/pdf/2006.11538.pdf).

For instance, if you want to use the grouped convolution: nn.Conv2d(in_channels=69, out_channels=64, kernel_size=3, padding=1, groups=4, bias=False) it will give you the same error, as the number of input feature maps (69) is not divisible by the number of groups (4). Similarly, the number of output feature maps should be divisible by the groups, for instance: nn.Conv2d(in_channels=64, out_channels=73, kernel_size=3, padding=1, groups=2, bias=False) it will give you also an error as the number of output feature maps (73) is not divisible by the number of groups (2).

So, when using our PyConv, you need to pay attention to the number input/output feature maps and also the the groups for each pyramid level (this becomes straight forward when all three (groups, input and output feature maps) are a power of 2).

czy112 commented 4 years ago

thanks!