We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← CNNs from Scratch step 5 of 15
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:
- Depthwise conv: Apply a separate filter to each input channel (1D for simplicity)
- 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:
-
Depthwise: for each channel c, convolve x[c] with dw_filters[c] (valid padding)
Output shape:
(C_in, L-K+1) -
Pointwise: multiply by pw_weights at each position
Output shape:
(C_out, L-K+1)
Output: Tensor of shape (C_out, L-K+1).
Loading visualization…
Nothing accepted yet. When a submission passes, the code that passed shows up
here, one entry per mode.
Stuck?
PyTorch reference solution
Sign in to attempt this problem and reveal the reference solution.