liveBook · Manning

Depthwise separable convolution

As explained in Deep Learning with Python, Third Edition

A convolution variant that applies per-channel spatial convolution followed by pointwise channel mixing to reduce parameters and computation.

Depthwise separable convolution replaces a regular Conv2D with two cheaper steps: a spatial convolution applied independently to each input channel, followed by a 1 × 1 pointwise convolution that mixes channels. It separates spatial-feature learning from channel-feature learning, using the prior that intermediate spatial patterns are correlated while channels are relatively independent. section 9.4

A smaller Xception-like ConvNet

In Keras, replace convolution layers inside repeated ConvNet blocks with SeparableConv2D, commonly alongside batch normalization, ReLU activation, max pooling, and residual connections. A dogs-versus-cats model built this way used 721,857 trainable parameters instead of 1,569,089 and reached 90.8% test accuracy instead of 83.9%. section 9.5

Use the layer when practical efficiency matters:

  • Expect substantially fewer parameters and floating-point operations than regular convolution, with comparable representational power. section 9.4
  • Prefer it especially for small models trained from scratch on limited data, where smaller models can converge faster and reduce overfitting. section 9.4
  • Treat it as one architecture choice among repeated blocks, increasing filter counts, residual connections, batch normalization, and pooling; tune hyperparameters systematically afterward. section 9.5
Figure 9.4 Depthwise separable convolution: a depthwise convolution followed by a pointwise convolution
depthwise separable conv

Use the diagram to trace the two-stage operation from depthwise spatial filtering to pointwise channel mixing. section 9.4

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains the depthwise-then-pointwise operation, its independence prior, efficiency benefits, and Keras application, without deriving its mathematics.
Examples
Uses Keras SeparableConv2D blocks in a mini Xception-like dogs-versus-cats classifier and compares its parameters and test accuracy.
What it assumes
Assumes familiarity with convolution layers and ConvNet architecture while teaching the layer’s two-stage decomposition directly.
What you can do after
Apply it via Keras SeparableConv2D when constructing smaller, more parameter-efficient ConvNet blocks.
How it connects
Connects spatial convolution, pointwise convolution, ConvNets, residual connections, batch normalization, and the Xception architecture.

Also explained in

Compare how 2 books explain depthwise separable convolution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.