# Mobile friendly networks

#### MobileNet

![](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LIRiSN8FgqD6L789ND9%2F-LIRj1az4hYwy2gPaYyZ%2FScreen%20Shot%202018-07-27%20at%2010.14.22%20AM.png?alt=media\&token=26917a6a-9ab1-4676-b30e-c51fe97f8003)

* Depth-wise and point-wise separated.

**Interpretation:**

* The basic idea is to replace a full convolutional operator with a factorized version that **splits convolution into two separate layers**. The first layer is called a depthwise convolution, it performs **lightweight filtering by applying a single convolutional filter per input channel**. The second layer is a 1 × 1 convolution, called a pointwise convolution, which is responsible for **building new features through computing linear combinations of the input channels**.

#### ShuffleNet

![](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LIRiSN8FgqD6L789ND9%2F-LIRjJr21_YvSU442z8M%2FScreen%20Shot%202018-07-27%20at%2010.15.36%20AM.png?alt=media\&token=ab829a68-5e49-4a07-a02a-5c61c7f1eb56)

* Depth-wise and point-wise separated
* skip connection
* group convolution in point-wise (**group convolution**: ensuring that each convolution operates only on the corresponding input channel group)
* channel shuffle after 1 x 1 point-wise group convolution
* 8 x downsample in first two convolutions (conv with stride2 + max pooling + conv with stride 2)

&#x20;  **Interpretation**:

* For each residual unit in ResNeXt, the pointwise convolutions occupy 93.4% multiplication-adds (cardinality = 32). **In tiny networks, expensive pointwise convolutions result in limited number of channels** to meet the complexity constraint, which might significantly damage the accuracy.&#x20;
* To address the issue, a straightforward solution is to apply group convolutions also on 1 × 1 layers, which will significantly reduce computation cost. However, if multiple group convolutions stack together, there is one side effect: **outputs from a certain channel are only derived from a small fraction of input channels**

![Stacking group convolutions](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LIRiSN8FgqD6L789ND9%2F-LIRnoZp22LSmozeNuwc%2FScreen%20Shot%202018-07-27%20at%2010.35.08%20AM.png?alt=media\&token=a72302d5-c404-4379-905a-b136156a8ec4)

* By implementing a **channel shuffling** operation, **obtaining input data from different groups is allowed** and then the input and output channels will be fully related. Specifically, for the feature map generated from the previous group layer, we can first divide the channels in each group into several subgroups, then feed each group in the next layer with different subgroups.&#x20;

![Group convolutions with channel shuffling](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LIRiSN8FgqD6L789ND9%2F-LIRoz7DRkHDbRaJToVE%2FScreen%20Shot%202018-07-27%20at%2010.35.16%20AM.png?alt=media\&token=f741539e-0573-4238-9905-cc2786be64cb)

#### MobileNet-V2

![](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LIS1f54E8_DgbF62QM3%2F-LIS1gfNPLoqJbUAT1m0%2FScreen%20Shot%202018-07-27%20at%2011.40.08%20AM.png?alt=media\&token=25af7415-be31-4e5d-880b-39f4a7539749)

![](https://443921002-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGHUhl6VYqrZm4Re77O%2F-LIS1f54E8_DgbF62QM3%2F-LIS30LYLmrDdIuQSD0N%2FScreen%20Shot%202018-07-27%20at%2011.42.45%20AM.png?alt=media\&token=4c74a8a8-c835-446c-a47c-b941d7c36042)

* For ReLU, **deep networks only have the power of a linear classifier on the non-zero volume part** of the output domain. \[本身用 ReLU 的有效区域就是 linear 的 ]
* On the other hand, **when ReLU collapses the channel (< 0), it inevitably loses information** in that channel. \[ < 0 区域的信息会丢失 ]
* Though traditionally networks have lots of channels, **even some channels have lost information, which might still be preserved in the other channels**. \[ 是因为一般 channel 数都很大，所以一部分丢失了也没关系。可当 inverted residual 在使用时，bottle neck 部分的 channel 数本身就很小，如果再丢失，会损失精度。 激活函数在高维空间能够有效的增加非线性，而在低维空间时则会破坏特征，不如线性的效果好。**由于第二个 pointwise 的主要功能就是降维**，因此按照上面的理论，降维之后就不宜再使用 ReLU 了 ]
* The total amount of **memory would be dominated by the size of bottleneck tensors**, rather than the size of tensors that are internal to bottleneck (and much larger). For residual connection structure, **the amount of memory is simply the maximum total size of combined inputs and outputs across all operations**. So that bottleneck with expansion is very memory efficient in inference part, since it has thin bottleneck.



#### ShuffleNet-V2 <a href="#shufflenet-v2" id="shufflenet-v2"></a>

![](https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LPDU9vTAwnjCs6CVlYs%2F-LPDUDS3WEcHeXf62zcb%2F-LPDXQxa5AoxLbyXHhh1%2FScreen%20Shot%202018-10-19%20at%203.54.30%20PM.png?alt=media\&token=88ba9762-0ef8-4840-b774-d083559cddd3)

* Equal channel width minimizes memory access cost (MAC).
* Excessive group convolution increases MAC.
* Network fragmentation reduces degree of parallelism.
* Element-wise operations are non-negligible.

