Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-241

BatchNorm Fold Bias

Problem

Fold batch normalization into the convolution bias.

For each output channel o return round((bias[o] - mean[o]) * gamma[o] / sqrt(var[o] + eps) + beta[o], 4).

Test cases

case 1
in: [[1,2],[0,1],[1,2],[1,4],[0,1],0]
expected: [1,2]
case 2
in: [[0],[1],[1],[1],[0],0.000001]
expected: [-1]
case 3
in: [[2,4],[0,2],[1,1],[4,4],[0,0],0]
expected: [1,1]
Starter codePython
def fold_conv_bias(bias, mean, gamma, var, beta, eps):
    # Your code here
    pass

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