depthwise-separable -- MobileNet conv, the FLOP cut
An ordinary image filter does two jobs at once: it looks at a patch of the picture, and it blends together all the channels stacked at each pixel. Doing both together costs the input channels times the output channels times the patch area — a product, and products grow fast. Splitting it in two turns that into a sum: first filter each channel by itself with no blending, then blend the channels at each single pixel with no patch. For a three-by-three filter the saving grows as you ask for more outputs, and it tops out just under nine times. A one-by-one kernel costs more than the filter it replaces. That climb, on the wide kernels, is most of why decent image models run on a phone. The cost is a slightly weaker operation, since the two jobs can no longer be tuned together.
Interactive page: the depthwise-separable convolution (MobileNet) -- factorize a standard conv into a depthwise conv (one k×k filter per input channel, no channel mixing) followed by a pointwise 1×1 conv (mixes channels, no spatial extent), and see the MAC/FLOP reduction it buys. Anchor: F (CNN / vision); Family F, builds on convolution.
What it shows
A standard conv mixes space and channels jointly: every output channel reads a k×k patch of every input channel, so the cost is a product:
full MACs = H·W·Cin·Cout·k²
MobileNet splits that into two cheap steps:
- Depthwise -- one
k×kfilter per input channel, applied independently (spatial filtering, NO channel mixing):H·W·Cin·k². Drawn as parallel channel→channel links (no crossing). - Pointwise -- a
1×1conv that mixes channels (channel mixing, NO spatial extent):H·W·Cin·Cout. Drawn as dense links with a1×1badge.
So the cost becomes a sum instead of a product, and the ratio is
full / dwsep = (k²·Cout) / (k² + Cout) = 1 / (1/Cout + 1/k²)
The ratio climbs toward k² as Cout grows (just under 9 for a 3×3) and drops below 1 for a 1×1 kernel, where the split costs more than the full conv.
The bottom bar compares full (one bar) vs depthwise + pointwise (two segments) to scale, with the live ratio and the parameter-count ratio.
Drag the input or output channel stack (↕) to change Cin/Cout and watch the bar and ratio update; sliders for k, Cin, Cout, and the feature-map size; the two stages (depthwise / pointwise) animate in turn; hover a stack or the bars to inspect counts.
Render tier
T1 (Canvas2D: the two connectivity diagrams + the MAC-comparison bar).
Wiring
layout.mount + controls (k, Cin, Cout, HW) + animate (the two-stage highlight) + onPointer drag-the-channel-stack + hover. ?k / ?Cin / ?Cout / ?HW / ?hover hooks. Source: page.js.