Involution: Inverting the Inherence of Convolution for Visual Recognition

https://arxiv.org/abs/2103.06255

------------------------------------------------------------------

2021-04-08

convolution

平移不变性  权值共享

每个通道提取不同的特征

Involution

kernel在空间范围上是不同的，在通道上共享

2.有中心点

```class Involution(nn.Module):
def __init__(self,channel,kernel_size,stride):
super(Involution,self).__init__()

self.stride=stride
self.kernel_size=kernel_size
self.channel=channel
self.reduction=4
self.group_channel=16
assert channel%self.group_channel==0
self.groups=channel//self.group_channel

self.conv1=nn.Sequential(
nn.Conv2d(channel,channel//self.reduction,1,bias=False),
nn.BatchNorm2d(channel//self.reduction),
nn.ReLU(inplace=True)
)

self.conv2=nn.Sequential(
nn.Conv2d(channel//self.reduction,kernel_size**2*self.groups,1,bias=False)
)

if stride>1:
self.avg=nn.AvgPool2d(stride,stride)

self.unf=nn.Unfold(kernel_size,1,(kernel_size-1)//2,stride)

def forward(self,x):
weight=self.conv2(self.conv1(x if self.stride==1 else self.avg(x)))
N,C,H,W=weight.size()
weight=weight.view(N,self.groups,self.kernel_size**2,H,W).unsqueeze(2)
out=self.unf(x).view(N,self.groups,self.group_channel,self.kernel_size**2,H,W)
out=(weight*out).sum(dim=3).view(N,self.channel,H,W)
return out```

Involution: Inverting the Inherence of Convolution for Visual Recognition

(0)
(0)