Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-158

Per-Channel Normalize

Problem

Normalize an H x W x C image with per-channel mean and standard deviation.

Return (v - mean[c]) / std[c] for every channel value, rounded to 4 decimal places.

Test cases

case 1
in: [[[[0,128,255],[64,64,64]]],[128,128,128],[64,64,64]]
expected: [[[-2,0,1.9844],[-1,-1,-1]]]
case 2
in: [[[[10,20],[30,40]]],[10,20],[5,10]]
expected: [[[0,0],[4,2]]]
case 3
in: [[[[128,128,128]]],[128,128,128],[64,64,64]]
expected: [[[0,0,0]]]
Starter codePython
def normalize_per_channel(image, mean, std):
    # Your code here
    pass

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