Involution: Inverting the Inherence of Convolution for Visual Recognition

Posted 水縸半城湮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Involution: Inverting the Inherence of Convolution for Visual Recognition相关的知识,希望对你有一定的参考价值。

https://arxiv.org/abs/2103.06255

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

2021-04-08

convolution

  平移不变性  权值共享

  每个通道提取不同的特征

Involution

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

卷积    组卷积   深度卷积

卷积核为奇数:

  1.padding是对称的    (k-1)//2

  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的主要内容,如果未能解决你的问题,请参考以下文章

Involution:空间不共享?可完全替代卷积的高性能算子 CVPR 2021

Java Inverting Switch语句

Applying and Inverting Transformations [on mask]

改进YOLO系列 | CVPR 2021 | Involution:超越convolution和self-attention的神经网络算子

阅读笔记Inverting Gradients -- How easy is it to break privacy in federated learning?

五期邹昱夫CCF-A(NeurIPS'19)Inverting gradients-how easy is it to break privacy in federated learning?