hard research

Depthwise Separable Convolution

Implement Depthwise Separable Convolution from “Xception: Deep Learning with Depthwise Separable Convolutions” (Chollet, 2017).

A depthwise separable convolution factorizes a standard convolution into:

  1. Depthwise conv: Apply a separate filter to each input channel (1D for simplicity)
  2. Pointwise conv: 1x1 convolution to mix channels

Given (1D case for simplicity):

  • x: shape (C_in, L) — C_in channels, length L
  • dw_filters: shape (C_in, K) — one filter per channel, kernel size K
  • pw_weights: shape (C_out, C_in) — pointwise mixing weights

Steps:

  1. Depthwise: for each channel c, convolve x[c] with dw_filters[c] (valid padding) Output shape: (C_in, L-K+1)
  2. Pointwise: multiply by pw_weights at each position Output shape: (C_out, L-K+1)

Output: Tensor of shape (C_out, L-K+1).

Hints

depthwise-separable xception chollet-2017 efficient-conv cnn
Detecting runtime...