Depthwise separable convolution cost savings
efficient convolution factorization.
separable conv splits standard conv into per-channel spatial filtering plus a 1x1 pointwise mix, cutting cost by roughly 1/N plus 1/k².
What's really being asked
Whether you can decompose a convolution's cost and articulate the assumption that makes the cheaper version work, the basis of MobileNet and Xception.
The full answer
A standard three by three convolution with M input channels and N output channels over a feature map of spatial size D by D costs roughly three times three times M times N times D times D multiply-adds and three times three times M times N parameters, because every output channel filters over all input channels and a spatial window jointly. A depthwise separable convolution splits this into two steps. The depthwise step applies a single three by three filter to each input channel independently, costing three times three times M times D times D. The pointwise step is a one by one convolution that combines the M channels into N outputs, costing M times N times D times D. The ratio of separable to standard cost is approximately one over N plus one over nine, so for typical channel counts you save roughly eight to nine times in both FLOPs and parameters.
The mistakes people make
Forgetting the pointwise step, which alone would prevent any cross-channel mixing. Miscomputing by treating depthwise as if it still spans all channels. Claiming there is no accuracy tradeoff; there is usually a small drop.
What usually comes next
What assumption justifies the factorization. Why does MobileNet add width and resolution multipliers. How does Xception interpret this. When does the small accuracy loss matter.
A concrete example
With M equals N equals two-fifty-six and a three by three kernel, the standard conv does three times three times two-fifty-six times two-fifty-six work per spatial location, while the separable version does three times three times two-fifty-six for depthwise plus two-fifty-six times two-fifty-six for pointwise. The ratio is about one ninth plus one over two-fifty-six, roughly an eight to nine times reduction, which is why MobileNets run on phones. The underlying hypothesis is that spatial filtering and cross-channel recombination are largely independent and can be learned in two cheaper steps rather than one expensive joint operation.
Interview question
What assumption makes depthwise separable convolution a reasonable replacement for a standard convolution?
- a.That the input always has very few channels
- b.That all channels carry identical information
- c.That spatial structure is irrelevant to the task
- d.That spatial and cross-channel correlations can be learned separatelyCorrect
Why? this is the answer
The factorization splits spatial filtering from channel mixing, assuming these correlations are roughly independent. It does not assume identical channels, few channels, or that spatial structure is irrelevant, indeed depthwise still filters spatially.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #computer-vision
- #depthwise-separable-convolution
- #mobilenet
- #efficiency
- #flops
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on computer-vision — each one lists the topics its interview covers.
See open roles