kaijieshi7 / Dynamic-convolution-Pytorch

Pytorch!!!Pytorch!!!Pytorch!!! Dynamic Convolution: Attention over Convolution Kernels (CVPR-2020)
553 stars 91 forks source link

替换mobilenetv2的分组卷积报错 #7

Open H-WU opened 3 years ago

H-WU commented 3 years ago

当替换分组卷积时,weight的维度和group的维度不对应。 RuntimeError: Given groups=1024, expected weight to be at least 1024 at dimension 0, but got weight of size [32, 32, 3, 3] instead aggregate_weight = torch.mm(softmax_attention, weight).view(-1, self.in_planes, self.kernel_size, self.kernel_size) 这一行应改成下面这样 aggregate_weight = torch.mm(softmax_attention, weight).view(-1, self.in_planes//self.groups, self.kernel_size, self.kernel_size)

kaijieshi7 commented 3 years ago

谢谢你的发现

Tengfei000 commented 2 years ago

当替换分组卷积时,weight的维度和group的维度不对应。 RuntimeError: Given groups=1024, expected weight to be at least 1024 at dimension 0, but got weight of size [32, 32, 3, 3] instead aggregate_weight = torch.mm(softmax_attention, weight).view(-1, self.in_planes, self.kernel_size, self.kernel_size) 这一行应改成下面这样 aggregate_weight = torch.mm(softmax_attention, weight).view(-1, self.in_planes//self.groups, self.kernel_size, self.kernel_size)

MobileNetV2替换动态卷积的结果你测了吗 我这边测试有较大的下降