MobileNet系列

MobileNet是用在移動端的輕量級CNN,本文簡單介紹MobileNet V1到V3的版本。

MobileNet V1

  • 主要特點:把卷積拆分爲Depthwise和Pointwise兩部分(深度可分離卷積Separable convolution),用步長爲2的卷積代替池化。
  • Depthwise和Pointwise圖解:

假設有N×H×W×CN \times H \times W \times C的輸入,普通卷積是做kk個3x3的卷積,且same padding,stride=1stride=1,輸出爲N×H×W×kN \times H \times W \times k。depthwise是將此輸入分爲group=Cgroup=C組,然後每組做一次卷積,相當於收集了每個channel的特徵,輸出依然是N×H×W×CN \times H \times W \times C。pointwise是做kk個普通的1x1卷積,相當於收集了每個點的特徵。depthwise+pointwise的輸出也爲N×H×W×kN \times H \times W \times k

  • 普通卷積和MobileNet卷積對比如下圖所示。計算一下兩者的參數量:

    • 普通卷積爲:C×k×3×3C \times k \times 3 \times 3

    • depthwise+pointwise:C×3×3+C×k×1×1C \times 3 \times 3 + C \times k \times 1 \times 1

    • 壓縮率爲depthwise+pointwiseconv=1k+13×3\frac{depthwise+pointwise}{conv}=\frac{1}{k} + \frac{1}{3 \times 3}

  • 進一步壓縮模型:引入了width multiplier,所有通道數乘以α(0,1]\alpha \in (0,1](四捨五入),以降低模型的寬度。

MobileNet V2

  • 主要特點:引入殘差結構;採用linear bottenecks + inverted residual結構,先升維後降維;使用relu6(最大輸出爲6)激活函數,使模型在低精度計算下有更強的魯棒性。
  • linear bottenecks + inverted residual結構如下圖所示。
    • V2版本依然是使用depthwise和pointwise,不同的是在depthwise前加了一個1x1卷積來擴大通道數目擴張係數爲tt,即通道數目擴大tt倍,以增加特徵豐富性。在pointwise之後再加1x1卷積將通道數目壓縮至原輸入的數目。
    • V2版本去掉了第二個1x1卷積之後的激活函數,稱爲linear bottleneck。作者認爲激活函數在高維空間能夠有效地增加非線性,但在地位空間會破壞特徵。

  • 與殘差模塊的對比:
    在這裏插入圖片描述

  • V2網絡結構:

MobileNet V3

  • 主要特點:引入SE(squeeze and excitation)結構;使用hard swish激活函數;頭部卷積通道數量由32變爲16;V2在預測部分使用了一個bottleneck結構來提取特徵,而V3用兩個1x1代替了這個操作;結構用NAS技術生成
  • SE輕量級注意力結構,如下圖所示。在depthwise後加入SE模塊,首先globalpool,然後1x1卷積將其通道壓縮爲原來的1/4,然後再1x1卷積擴回去,再乘以SE的輸入。SE即提高了精度,同時還沒有增加時間消耗。

  • 尾部修改:

  • hard swish激活函數如下所示。swish激活函數可以提高精度,但計算量比較大,作者用relu近似模擬,稱爲hard swish

swichx=xσ(x)hswish[x]=xReLU6(x+3)6 \Bbb{swich} x=x \cdot \sigma(x) \\ \Bbb{h-swish}[x]=x\frac{ReLU6(x+3)}{6}

img

  • v2頭部卷積爲32x3x3,作者發現可以改爲16,保證了精度且降低了延時時間。

  • 網絡結構搜索,借鑑了MansNet和NetAdapt,這部分以後再詳細補充。

  • 網絡結構:

img

img

參考文獻

[1] https://zhuanlan.zhihu.com/p/35405071

[2] https://blog.csdn.net/mzpmzk/article/details/82976871

[3] https://www.cnblogs.com/darkknightzh/p/9410540.html

[4] https://blog.csdn.net/DL_wly/article/details/90168883

[5] https://blog.csdn.net/Chunfengyanyulove/article/details/91358187

[6] https://www.jianshu.com/p/9af2ae74ec04

  • https://www.cnblogs.com/dengshunge/p/11334640.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章