How does depthwise separable convolution reduce computation?
Depthwise separable convolution reduces computation by replacing one expensive spatial convolution with two smaller operations: a depthwise convolution that filters each input channel independently, followed by a 1×1 pointwise convolution that mixes channels.
Why is it cheaper?
A standard K×K convolution jointly performs spatial filtering and channel mixing for every output channel. Depthwise separable convolution splits those jobs:
- Depthwise `K×K`: Apply one spatial filter per input channel.
- Pointwise `1×1`: Combine the resulting channels to produce the desired output channels.
Numerical example
Assume 32 input channels, 64 output channels, a `3×3` kernel, and one depthwise filter per input channel.
- Standard convolution:
3 × 3 × 32 × 64 = 18,432weights. - Depthwise step:
3 × 3 × 32 = 288weights. - Pointwise step:
1 × 1 × 32 × 64 = 2,048weights. - Combined:
288 + 2,048 = 2,336weights.
That is 16,096 fewer weights (about 87.3% reduction), or about 7.9× fewer multiply-accumulate terms per output spatial position under matching output dimensions. Biases and other operations are excluded from this comparison.
General formula
Let K be the square kernel size, Cin the input channels, and Cout the output channels:
- Standard:
K² × Cin × Cout - Depthwise separable:
(K² × Cin) + (Cin × Cout)
Why is it useful? MobileNet uses this pattern to make CNNs lighter for mobile and embedded vision. It can greatly reduce parameters and arithmetic, although actual latency depends on the hardware and implementation, and the factorization can change model accuracy.
Related: “What is a depthwise convolution?” and “What is a pointwise convolution?”
Research: MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications. Documentation: PyTorch Conv2d.
Sources & Research References
Learning Sequence
Deep Learning Curriculum
Explore Related Questions
Deepen your understanding across related Deep Learning topics.