All problems
Group Conv Output
Problem
Apply a grouped convolution in valid mode.
The C input channels are split into groups; one shared k x k kernel per group is cross-correlated with every channel of that group and the responses are summed, producing one output channel per group. Return an (H - k + 1) x (W - k + 1) x groups map.
Test cases
case 1
in: [[[[1,2],[3,4]],[[5,6],[7,8]],[[1,1],[1,1]],[[2,2],[2,2]]],[[[1,0],[0,0]],[[0,0],[0,1]]],2]
expected: [[[1,8]],[[5,1]],[[1,2]]]
case 2
in: [[[[1,1,1],[1,1,1],[1,1,1]],[[1,1,1],[1,1,1],[1,1,1]]],[[[1,1],[1,1]]],1]
expected: [[[12],[12]]]
case 3
in: [[[[1,5],[2,6]],[[3,7],[4,8]]],[[[1,1],[1,1]],[[1,1],[1,1]]],2]
expected: [[[10,26]]]
Starter codePython
def group_conv(feature, kernels, groups):
# Your code here
pass3 test cases · run your code against them in the editor