1. 程式人生 > >Inception系列理解

Inception系列理解

部落格:[部落格園](https://www.cnblogs.com/shine-lee/) | [CSDN](https://blog.csdn.net/blogshinelee) | [blog](https://blog.shinelee.me/) [TOC] # 寫在前面 Inception 家族成員:Inception-V1(GoogLeNet)、BN-Inception、Inception-V2、Inception-V3、Inception-ResNet-V1、Inception-V4、Inception-ResNet-V2。 Inception系列網路結構可以模組化為: $$ Input \rightarrow Stem \rightarrow A \rightarrow ReducitonA \rightarrow B \rightarrow ReductionB \rightarrow C \rightarrow Avg\ Pooling (+ Linear) \rightarrow feature $$ - **Stem**:前處理部分 - **A B C**:**網路主體**“三段式”,A B C每段的輸入feature size依次折半,channel增加 - **ReductionA B**:完成feature size折半操作(降取樣) - **Avg Pooling (+ Linear)**:後處理部分 Inception系列的演化過程就是上面各環節不斷改進(越來越複雜)的過程,其進化方向大致為 - **Stem**:大卷積層→多個小卷積層堆疊→multi-branch 小卷積層堆疊 - **A B C**:相同multi-branch結構→每階段不同multi-branch結構→每階段不同**Residual+multi-branch**結構,big convolution→ small convolution + BN → **factorized convolution** - **ReductionA B**:max pooling → 不同multi-branch conv(stride 2)結構 - **後處理**:Avg Pooling + Linear → Avg Pooling 效能進化如下圖所示,single model通過center crop 在ImageNet上 Top1 和 Top5 準確率, ![https://arxiv.org/abs/1810.00736](https://s1.ax1x.com/2020/04/03/GU8eTe.png) 具體如下。 # Inception-V1 (GoogLeNet) Inception-V1,更被熟知的名字為GoogLeNet,意向Lenet致敬。 通過增加網路深度和寬度可以提升網路的表徵能力。 增加寬度可以簡單地通過增加捲積核數量來實現,GoogLeNet在增加捲積核數量的同時,**引入了不同尺寸的卷積核,來捕捉不同尺度的特徵**,形成了**multi-branch結構**——這是GoogLeNet網路結構的最大特點,如下圖所示,然後將不同branch得到的feature map 拼接在一起,為了讓feature map的尺寸相同,每個branch均採用SAME padding方式,同時**stride為1(包括max pooling)**。為了降低計算量,又**引入了$1\times 1$卷積層來降維**,如下圖右所示,該multi-branch結構稱之為一個Inception Module,在GoogLeNet中採用的是下圖右的Inception Module。 ![source: http://arxiv.org/abs/1409.4842](https://s1.ax1x.com/2020/03/24/8L9wqI.png) 直接增加深度會導致淺層出現嚴重的梯度消失現象,GoogLeNet引入了**輔助分類器(Auxiliary Classifier)**,在淺層和中間層插入,**來增強回傳時的梯度訊號,引導淺層學習到更具區分力的特徵。** ![source: http://arxiv.org/abs/1409.4842](https://s1.ax1x.com/2020/03/24/8Li1Zn.png) 最終,網路結構如下,主體三段式A B C 即 3x、4x、5x, ![source: http://arxiv.org/abs/1409.4842](https://s1.ax1x.com/2020/03/24/8LFuY6.png) GoogLeNet網路結構的特點可以概括為, - 同時使用不同尺寸的卷積核,形成**multi-branch**結構,來捕捉不同尺度的特徵 - **使用$1 \times 1$卷積降維**,壓縮資訊,降低計算量 - 在classifier前使用**average pooling** # BN-Inception BN-Inception網路實際是在Batch Normalization論文中順帶提出的,旨在表現BN的強大。 ![source: http://arxiv.org/abs/1512.00567](https://s1.ax1x.com/2020/03/25/8jSbGT.png) 與GoogLeNet的不同之處在於, - 在每個啟用層前**增加BN層** - **將Inception Module中的$5 \times 5$ 卷積替換為2個$3\times 3$ 卷積**,如上圖所示 - 在Inception 3a和3b之後增加Inception 3c - 部分Inception Module中的Pooling層改為average pooling - 取消Inception Module之間銜接的pooling層,而將下采樣操作交給Inception 3c和4e,令stride為2 BN-Inception網路結構如下 ![source: http://arxiv.org/abs/1502.03167](https://s1.ax1x.com/2020/03/24/8LuVmT.png) # Inception-V2, V3 Inception V2和V3出自同一篇論文[Rethinking the Inception Architecture for Computer Vision](https://arxiv.org/abs/1512.00567)。 GoogLeNet和BN-Inception網路結構中Inception Module可分為3組,稱之為3x、4x和5x(即主體三段式A B C),GoogLeNet和BN-Inception這3組採用相同Inception Module結構,只是堆疊的數量不同。 Inception V2和V3與以往最大的不同之處在於3組分別使用了不同結構的Inception Module,分別如下圖從左到右所示, ![source: http://arxiv.org/abs/1512.00567](https://s1.ax1x.com/2020/03/25/8jioCt.png) 具體地, - 3x使用的Inception Module與BN-Inception相同,即將$5\times 5$拆分成2個堆疊的$3\times 3$ ; - 4x使用的Inception Module採用了factorized convolutions ,**將2維卷積拆分成2個堆疊的1維卷積,可類比傳統計算機視覺中的“行列可分解卷積”,但中間夾了個啟用**,1維卷積的長度為7; - 5x使用的Inception Module,1維卷積不再堆疊而是並列,將結果concat; 除此之外, - 3x和4x之間,4x和5x之間,均不存在銜接的池化層,下采樣通過Inception Module中的stride實現 - 取消了淺層的輔助分類器,只保留中層的輔助分類器 - 最開始的幾個卷積層調整為多個堆疊的$3\times 3$ 卷積 據論文所述,V2的網路結構如下 ![source: http://arxiv.org/abs/1512.00567](https://s1.ax1x.com/2020/03/25/8j10V1.png) 據論文所述,V3與V2的差異在於, - RMSProp Optimizer - **Label Smoothing**,**訓練中使用的label為one hot label與均勻分佈的加權**,可以看成一種正則 - Factorized $7 \times 7$,即將第一個$7 \times 7$卷積層變為堆疊的3個$3 \times 3$ - BN-auxiliary,輔助分類器中的全連線層也加入BN 但是,**實際釋出的Inception V3完全是另外一回事**,參見[pytorch/inception](https://github.com/pytorch/vision/blob/master/torchvision/models/inception.py),有人繪製了V3的網路架構如下——網上少有繪製正確的,下圖中亦存在小瑕疵,最後一個下采樣Inception Module中$1\times 1$的stride為1。 需要注意的是,起下采樣作用兩個Inception Module並不相同。 ![source: https://www.researchgate.net/figure/VGG16-VGG19-Inception-V3-Xception-and-ResNet-50-architectures_fig1_330478807](https://s1.ax1x.com/2020/03/25/8jt5Is.png) 有的時候,Inception-V2和BN-Inception是混淆的。從Inception-V3開始,Inception架構變得越來越不像人搞的…… # Inception-V4,Inception-ResNet-v1,Inception-ResNet-v2 Inception-V4,Inception-ResNet-v1 和 Inception-ResNet-v2出自同一篇論文[Inception-V4, Inception-ResNet and the Impact of Residual Connections on Learning](https://arxiv.org/abs/1602.07261), Inception-V4相對V3的主要變化在於,**前處理使用更復雜的multi-branch stem模組**,主體三段式與V3相同。 ![https://towardsdatascience.com/review-inception-v4-evolved-from-googlenet-merged-with-resnet-idea-image-classification-5e8c339d18bc](https://s1.ax1x.com/2020/04/01/G3gdq1.png) Inception-ResNet-V1與Inception-ResNet-V2,將Inception與ResNet結合,**使用Inception結構來擬合殘差部分**,兩者在A B C部分結構相同,只是後者channel數更多,兩者的主要差異在前處理部分,後者採用了更復雜的multi-branch stem結構(與V4相同)。相比純Inception結構,**引入ResNet結構極大加快了網路的收斂速度**。 ![https://www.aiuai.cn/aifarm465.html](https://s1.ax1x.com/2020/04/01/G3TWpq.png) ![https://www.aiuai.cn/aifarm465.html](https://s1.ax1x.com/2020/04/01/G3TInU.png) 以上。 # 參考 - [GoogLeNet, Inception-V1: Going Deeper with Convolutions](https://arxiv.org/abs/1409.4842) - [Batch Normalization, BN-Inception: Accelerating Deep Network Training by Reducing Internal Covariate Shift](https://arxiv.org/abs/1502.03167) - [Inception-V2, V3: Rethinking the Inception Architecture for Computer Vision](https://arxiv.org/abs/1512.00567) - [Inception-V4, Inception-ResNet and the Impact of Residual Connections on Learning](https://arxiv.org/abs/160