Designing Compact Networks: Taking Convolution Apart

The classic networks (AlexNet, VGG, Inception, ResNet, SENet, and so on) were mostly built to “chase accuracy.” But to actually deploy them—with a smaller runtime memory footprint, lower latency, and higher throughput—you need purpose-built compact network architectures. This piece walks through the design ideas behind a few of the main lines of work.

MobileNet: Depthwise Separable Convolution

MobileNet is more or less the starting point of compact network design. As the name suggests, it targets mobile deployment, and its biggest contribution is splitting the conventional convolution into two steps: depthwise convolution and 1×11\times1 convolution (pointwise convolution).

The filters of standard convolution, depthwise convolution, and 1×1 convolution
The filters of standard convolution vs. depthwise convolution vs. 1×1 convolution.
The MobileNet architecture
The overall MobileNet architecture.

We can analyze this quantitatively. Suppose a DF×DF×MD_F\times D_F\times M tensor is turned by convolution into a DF×DF×ND_F\times D_F\times N tensor, with kernel size DKD_K. The FLOPs of a standard convolution are:

FLOPsstd=DK×DK×M×N×DF×DF\text{FLOPs}_{\text{std}}=D_K \times D_K \times M \times N \times D_F \times D_F

After splitting into depthwise + 1×11\times1:

FLOPsdw+pw=DK×DK×M×DF×DF+M×N×DF×DF\text{FLOPs}_{\text{dw+pw}}=D_K \times D_K \times M \times D_F \times D_F + M \times N \times D_F \times D_F

The ratio of the two is:

FLOPsdw+pwFLOPsstd=1N+1DK×DK\frac{\text{FLOPs}_{\text{dw+pw}}}{\text{FLOPs}_{\text{std}}}=\frac{1}{N}+\frac{1}{D_K\times D_K}

The most common choice is the 3×33\times3 convolution (DK=3D_K=3), and when the number of output channels NN is large, this split can cut FLOPs to as little as 19\tfrac{1}{9} of a standard convolution. But note: a 9× drop in FLOPs does not mean a 9× speedup in practice—inference frameworks usually implement convolution with im2col+GEMM or Winograd, and depthwise separable convolution doesn’t effectively reduce memory access cost, so the measured speedup is actually quite limited. The parameter-count analysis is the same, with a ratio of 1N+1DK2\tfrac{1}{N}+\tfrac{1}{D_K^2} as well; the reduction in parameters is “more real” than the reduction in FLOPs, because it genuinely saves space when stored on disk—unlike FLOPs, which are constrained by software implementation and hard to translate into a real speedup.

ShuffleNet: Grouped 1×1 Convolution + Channel Shuffle

ShuffleNet came a few months after MobileNet, and it goes a step further on the 1×11\times1 convolution: besides keeping the depthwise 3×33\times3 convolution, it also groups the standard 1×11\times1 convolution, and after grouping it introduces channel shuffle so that information from each group of channels can be fused in the next layer. Note that channel shuffle isn’t a truly random permutation—in PyTorch, for example, it’s implemented with reshape + permute.

Channel shuffle in ShuffleNet
Channel shuffle: with grouped convolution alone, the groups don’t communicate with each other (a); after the shuffle, channel information is fused across groups (c).

The whole of ShuffleNet is built by stacking multiple blocks:

The ShuffleNet block
The ShuffleNet block: replace the 1×1 convolution with a grouped convolution and add channel shuffle.
The ShuffleNet architecture
The overall ShuffleNet architecture.

Quantitatively: channel shuffle itself neither adds nor removes FLOPs/parameters, but it changes the in-memory layout of the feature maps, imposing strided memory access cost on the next layer. And a 1×11\times1 convolution with GG groups has FLOPs of M×N×DF×DFG\tfrac{M\times N\times D_F\times D_F}{G}—compared with a standard 1×11\times1 convolution, both FLOPs and parameter count drop to 1G\tfrac{1}{G}. For a fixed total network FLOPs, more groups means you can use more filters; achieving the best accuracy requires a careful trade-off between the two.

MobileNetV2: Inverted Residual

MobileNetV2 brings ResNet’s residual connection and bottleneck into MobileNet, but uses the opposite inverted bottleneck: first a 1×11\times1 convolution to expand the channel count, then a depthwise separable convolution, and finally a second 1×11\times1 convolution to bring the channels back down to the input size.

The MobileNetV2 inverted residual block
ResNet’s bottleneck (a) vs. MobileNetV2’s inverted bottleneck (b).
The MobileNetV2 architecture
MobileNetV2: t is the expansion ratio, c is the output channels, n is the number of repeats, and s is the stride.

It didn’t invent any new compact operation; instead, it folds residual connections, bottlenecks, and other techniques that boost fitting capacity into a compact network, pushing accuracy a bit further. It’s worth mentioning that MobileNetV2 later became the backbone for many architecture-search methods (both MobileNetV3 and EfficientNet below are built on it).

ShuffleNetV2: Four Guidelines Built Around Memory Access Cost

ShuffleNetV2, in its paper, places its emphasis on an often-overlooked metric—memory access cost (MAC)—and from it derives four guidelines for designing compact networks.

Guideline 1: Keep a convolution’s input and output channel counts as equal as possible. Take the 1×11\times1 convolution as an example: with input/output channels c1,c2c_1,c_2 and a feature map of h×wh\times w, we have FLOPs=hwc1c2\text{FLOPs}=h\,w\,c_1\,c_2. For fixed FLOPs, the memory access cost is

MAC=hw(c1+c2)+c1c2  2hwFLOPs+FLOPshw\text{MAC}=h\,w\,(c_1+c_2)+c_1 c_2 \ \ge\ 2\sqrt{h\,w\cdot\text{FLOPs}}+\frac{\text{FLOPs}}{h\,w}

By the AM–GM inequality, MAC has a lower bound, attained when c1=c2c_1=c_2. Experiments confirm this: at the same FLOPs, the measured speed is fastest when the input/output channel ratio is 1:11:1 (the conclusion holds on both GPU and ARM).

c1:c2(c1,c2) GPU x1GPU x1GPU x2GPU x4(c1,c2) ARM x1ARM x1ARM x2ARM x4
1:1(128,128)1480723232(32,32)76.221.75.3
1:2(90,180)1296586206(22,44)72.920.55.1
1:6(52,312)876489189(13,78)69.117.94.6
1:12(36,432)748392163(9,108)57.615.14.4

Guideline 1: at the same FLOPs, a 1:1 input/output channel ratio is fastest.

Guideline 2: Too many groups increases MAC. For a 1×11\times1 convolution with gg groups:

MAC=hw(c1+c2)+c1c2g=hwc1+FLOPsgc1+FLOPshw\text{MAC}=h\,w\,(c_1+c_2)+\frac{c_1 c_2}{g}=h\,w\,c_1+\frac{\text{FLOPs}\cdot g}{c_1}+\frac{\text{FLOPs}}{h\,w}

For fixed FLOPs, MAC grows as gg grows.

gc GPU x1GPU x1GPU x2GPU x4c CPU x1CPU x1CPU x2CPU x4
1128245112894376440.010.22.3
218017258733419035.09.52.2
4256102664433812832.98.72.1
836063444523018027.87.51.8

Guideline 2: at the same FLOPs, more groups means slower.

Guideline 3: Too much fragmentation reduces parallelism. Too many small serial/parallel branches in a network weaken the degree of parallel computation. But deeper structures often have higher accuracy, so you have to trade off between accuracy and parallel speedup.

Serial and parallel structures
Fragmented structures with different counts and serial/parallel arrangements.
structureGPU c=128GPU c=256GPU c=512CPU c=64CPU c=128CPU c=256
1-fragment2446127443440.210.12.3
2-fragment-series179090933638.610.12.2
4-fragment-series75274534938.410.12.3
2-fragment-parallel153780332033.49.12.2
4-fragment-parallel69157229235.08.42.1

Guideline 3: at the same FLOPs, fewer fragments is faster; for the same number of fragments, serial is faster than parallel.

Guideline 4: Don’t ignore the cost of element-wise operations. The time of an operation is made up of two parts, MAC and FLOPs. A convolution’s FLOPs far exceed its MAC, but in operations with very small FLOPs—like element-wise add and ReLU—MAC is the dominant cost and can’t be ignored.

ReLUshort-cutGPU c=32GPU c=64GPU c=128CPU c=32CPU c=64CPU c=128
yesyes24272066143656.716.95.0
yesno26472256173561.918.85.2
noyes26722121145857.318.25.1
nono28422376178266.320.25.4

Guideline 4: element-wise operations like ReLU and residual connections also carry a non-trivial cost.

Accordingly, the ShuffleNetV2 block is almost entirely different from V1: it no longer uses grouped 1×11\times1 convolution, switching instead to channel split (which keeps the residual connection while avoiding the MAC increase from grouped convolution—Guideline 2); and the Channel Split, Concat, and Channel Shuffle within the block can even be fused into a single operation to reduce MAC (Guideline 4).

The ShuffleNetV2 block
A comparison of the ShuffleNetV1 (a, b) and ShuffleNetV2 (c, d) blocks.
The overall ShuffleNetV2 architecture
The overall ShuffleNetV2 architecture.

MobileNetV3: h-swish

MobileNetV3 is obtained by applying automated search (MnasNet + NetAdapt compression) on top of MobileNetV2; it mainly changes the number of convolution layers, the kernel sizes, and the channel counts, and uses SE modules in some layers. In addition, it swaps the activation function in the deeper layers from ReLU to hard-swish:

h-swish(x)=xReLU6(x+3)6\text{h-swish}(x)=x\,\frac{\text{ReLU6}(x+3)}{6}

The original swish is swish(x)=xσ(x)\text{swish}(x)=x\cdot\sigma(x), but the sigmoid is expensive to compute; hard-swish uses an approximation to get nearly the same effect at far lower cost.

The hard-swish activation function
hard-swish: approximating swish with ReLU6 to avoid the heavy computation of the sigmoid.
MobileNetV3-small
The structure of MobileNetV3-small (there is also a large version).

EfficientNet: Compound Scaling

EfficientNet was born at almost the same time as MobileNetV3 and is also derived from an MnasNet search, but the search uses only a simple grid search. Its core is a network scaling method: since a compact network can reach decent accuracy at very small FLOPs, then to get higher accuracy you can just scale it up. The scaling spans three dimensions: width, depth, and input resolution.

Scaling a neural network
The three kinds of scaling—width / depth / resolution—and their compound scaling.

The scaling factor for each dimension is decoupled into a relative factor and an overall factor ϕ\phi:

depth:d=αϕ,width:w=βϕ,resolution:r=γϕ\text{depth}:d=\alpha^{\phi},\quad \text{width}:w=\beta^{\phi},\quad \text{resolution}:r=\gamma^{\phi}
s.t.αβ2γ22,α,β,γ1\text{s.t.}\quad \alpha\cdot\beta^2\cdot\gamma^2\approx2,\quad \alpha,\beta,\gamma\ge1

The reason for the constraint αβ2γ22\alpha\beta^2\gamma^2\approx2: FLOPs grow quadratically with width and resolution and linearly with depth, so constraining αβ2γ2\alpha\beta^2\gamma^2 to a constant lets any scaling keep FLOPs at a controllable level. During the search, ϕ\phi is fixed at 11 and a grid search finds the best α,β,γ\alpha,\beta,\gamma; afterward, tuning ϕ\phi scales the network to any FLOPs.

Compound scaling vs. single-dimension scaling
Compound scaling achieves higher accuracy than scaling a single dimension, at the same FLOPs.
The EfficientNet-B0 architecture
EfficientNet-B0 (the base network for scaling, found by an MnasNet search), scaling up to B1–B7.

GhostNet: Generating “Ghost” Features with Cheap Operations

GhostNet also takes the decomposition route, but from a distinctive starting point: visualizing feature maps reveals that many channels’ feature maps are very similar to one another—so there’s no need to compute them all with an expensive standard convolution.

Many of the feature maps from a standard convolution are near-duplicates
Among the feature maps computed by a standard convolution, quite a few are highly similar to each other.

So GhostNet splits the standard convolution into two steps: first compute part of the output with a standard convolution using fewer filters, then “generate” the other part on top of it with a cheap operation (such as a linear transform or depthwise separable convolution), and finally concat them together.

Standard convolution vs. the convolution in a Ghost module
Standard convolution (a) vs. the Ghost module (b): a small standard convolution + cheap operations to generate the remaining features.

Quantitative analysis: with kernel kk, input channels cc, and output n×h×wn\times h\times w, the standard convolution’s FLOPs are nhwck2n\,h\,w\,c\,k^2. If the Ghost module computes mm channels in the first step, uses a depthwise separable convolution of size dd for the cheap operation, and lets s=nms=\tfrac{n}{m}, then the speedup ratio is

RFLOPs=nhwck2mhwck2+(nm)hwd2=ck21sck2+s1sd2sR_{\text{FLOPs}}=\frac{n\,h\,w\,c\,k^2}{m\,h\,w\,c\,k^2+(n-m)\,h\,w\,d^2}=\frac{c\,k^2}{\tfrac{1}{s}c\,k^2+\tfrac{s-1}{s}d^2}\approx s

(The approximation uses dkd\approx k and scs\ll c.) The compression ratio for parameter count is likewise about ss.

A block in GhostNet
The GhostNet block: similar to MobileNetV2, expanding the feature map in the middle and then compressing it.
The overall GhostNet architecture
The overall GhostNet architecture.

From MobileNet taking convolution apart, to ShuffleNetV2 fixating on memory access, to GhostNet reusing similar features—the through-line of compact network design has always been repeatedly trading off among FLOPs, memory access, and accuracy. And MobileNetV3 and EfficientNet have already replaced “designed by hand” with “found by automated search,” which is precisely the direction of neural architecture search (NAS).

References

  • Howard, Andrew G., et al. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications. arXiv:1704.04861, 2017.
  • Zhang, Xiangyu, et al. ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices. CVPR, 2018.
  • Ma, Ningning, et al. ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design. ECCV, 2018.
  • Sandler, Mark, et al. MobileNetV2: Inverted Residuals and Linear Bottlenecks. CVPR, 2018.
  • Howard, Andrew, et al. Searching for MobileNetV3. arXiv:1905.02244, 2019.
  • Tan, Mingxing, Le, Quoc V. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. arXiv:1905.11946, 2019.
  • Han, Kai, et al. GhostNet: More Features from Cheap Operations. CVPR, 2020.
  • Tan, Mingxing, et al. MnasNet: Platform-Aware Neural Architecture Search for Mobile. CVPR, 2019.
  • Jia, Yangqing, et al. Caffe: Convolutional Architecture for Fast Feature Embedding. ACM MM, 2014.
  • Lavin, Andrew, Gray, Scott. Fast Algorithms for Convolutional Neural Networks (Winograd). CVPR, 2016.