Skip to content
DeepForgeby svx
All problems

Feature Normalization In FA

Problem

Normalize features with per-feature mean and standard deviation: (x - mean) / (std + epsilon) elementwise. The epsilon prevents division by zero for constant features.

Hint

Normalizing features keeps one large-scale dimension from dominating the gradient.

Test cases

case 1
in: [[2,4],[1,2],[1,2],1e-8]
expected: [0.9999999900000002,0.999999995]
case 2
in: [[0],[5],[0],1e-8]
expected: [-500000000]
case 3
in: [[1,-1],[0,0],[0.5,0.5],0]
expected: [2,-2]
Starter codePython
def feature_normalization(features, mean, std, epsilon):
    # Your code here
    pass

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