Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-242

Conv+ReLU Fusion

Problem

Apply a fused valid-mode convolution, bias add and ReLU to a 2D image.

out[i][j] = max(0, bias + sum of the k x k patch times the kernel). Return integer values.

Test cases

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

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