Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-238

Depthwise Conv Output

Problem

Apply a depthwise convolution in valid mode.

kernels[c] is a k x k kernel for channel c; each output channel is the cross-correlation of its input channel with its kernel. Return an (H - k + 1) x (W - k + 1) x C map of integers.

Test cases

case 1
in: [[[[1,2],[3,4]],[[5,6],[7,8]]],[[[1,0],[0,0]],[[0,0],[0,1]]]]
expected: [[[1,8]]]
case 2
in: [[[[1,1],[2,2],[3,3]],[[4,4],[5,5],[6,6]],[[7,7],[8,8],[9,9]]],[[[1,1],[1,1]],[[1,-1],[-1,1]]]]
expected: [[[12,0],[16,0]],[[24,0],[28,0]]]
case 3
in: [[[[1],[2]],[[3],[4]]],[[[1,0],[0,1]]]]
expected: [[[5]]]
Starter codePython
def depthwise_conv(feature, kernels):
    # Your code here
    pass

3 test cases · run your code against them in the editor