Batch Normalization Forward
Batch Normalization
Batch normalization normalizes each feature across the batch dimension, stabilizing training and allowing higher learning rates.
For a mini-batch of activations of shape (m, d):
Each column (feature) is independently normalized to zero mean and unit variance. The prevents division by zero.
Note: In the full layer, is then scaled and shifted by learned parameters and — we skip that here.
Your task:
Implement batch_normalize(X, eps) that normalizes each feature column.
Example Tests
Sum of normalized output is 0 (all columns are zero-mean)
Input: {"X":[[1,10],[2,20],[3,30]],"eps":0}
Expected: 0
Each column has unit std (check element value)
Input: {"X":[[1,2],[3,4],[5,6]],"eps":0}
Expected: [[-1.22474,-1.22474],[0,0],[1.22474,1.22474]]
Output shape preserved
Input: {"X":[[1,2,3],[4,5,6]],"eps":1e-8}
Expected: [2,3]