轻量化网络(六)GhostNet: More Features from Cheap Operations

这篇由华为在2019出品的轻量化网络,主要是基于在特征中有很大的冗余,所以通过一些操作来减少通道数从而实现网络轻量化。作者提出的 Ghost module 可以在已有的神经网络中即插即用。在相似的计算量下,网络性能超过了MobileNet v3。
论文链接
Tensorflow实现
Pytorch实现
一、Ghost module
神经网络中使用了大量的卷积核,导致了很大的计算量。如Figure 1所示,在同个特征(feature map)中,有许多相似的图。一个特征可以由其相似的特征得到,所以没有必要消耗更多的资源去产生那么多的特征。假定一些特征可以由一些简单的操作从现在的特征中得到,那么可以减少大量的计算。取名为“GhostNet”就是这个原因,一些由简单操作得到的特征是其原来特征的“ghost”。
在这里插入图片描述
Figure 2(a)是标准卷积。假设输入特征大小为 c × h × w c \times h \times w c×h×w,卷积核为 c × k × k × n c \times k \times k \times n c×k×k×n。为了降低计算,首先使用 c × k × k × m c \times k \times k \times m c×k×k×m卷积核,其中 m ≤ n m \le n mn。为了进一步得到 n n n个特征,使用一系列简单的操作。在前一步的操作上,使用线性操作 Φ \Phi Φ来生成,如Figure 2(b)所示。

在这里插入图片描述

#GhostModule具体实现
class GhostModule(nn.Module):
    def __init__(self, inp, oup, kernel_size=1, ratio=2, dw_size=3, stride=1, relu=True):
        super(GhostModule, self).__init__()
        self.oup = oup
        init_channels = math.ceil(oup / ratio)
        new_channels = init_channels*(ratio-1)
        self.primary_conv = nn.Sequential(
            nn.Conv2d(inp, init_channels, kernel_size, stride, kernel_size//2, bias=False),
            nn.BatchNorm2d(init_channels),
            nn.ReLU(inplace=True) if relu else nn.Sequential(),
        )
        self.cheap_operation = nn.Sequential(
            nn.Conv2d(init_channels, new_channels, dw_size, 1, dw_size//2, groups=init_channels, bias=False),
            nn.BatchNorm2d(new_channels),
            nn.ReLU(inplace=True) if relu else nn.Sequential(),
        )
        def forward(self, x):
        x1 = self.primary_conv(x)
        x2 = self.cheap_operation(x1)
        out = torch.cat([x1,x2], dim=1)
        return out[:,:self.oup,:,:]

二、网络结构
Figure 3是Ghost unit结构,其中堆叠了两个Ghost module,第一个Ghost module作为扩展层升维,第二个降维。Table 1是整个GhostNet网络结构,使用了Ghost unit替代了MobileNet中的单元。
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值