Batch Normalization Forward

~15 mincode completion

Implement batch_normalize(X, eps) that normalizes each feature column.

Examples

Each column has unit std (check element value)

Input
batch_normalize([[1, 2], [3, 4], [5, 6]], 0)
Output
[[-1.22474, -1.22474], [0, 0], [1.22474, 1.22474]]

Hints

Hint 1

The reduction runs down the columns, so pass .

Hint 2

Watch for this: normalized along wrong axis.

Requirements

  • X: Input matrix of shape (m, d)

  • eps: Small constant for numerical stability

  • Return Normalized matrix of shape (m, d).

Constraints

  • Allowed library: NumPy only

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~15 min

8 employers weight this skill

4 frontier labs, 2 big tech firms, 1 autonomy company, 1 enterprise vendor. Top match scores 78.

Python
import numpy as np

def batch_normalize(X: np.ndarray, eps: float = 1e-8) -> np.ndarray:
    """
    Normalize each feature (column) of X to zero mean and unit variance.

    Args:
        X:   Input matrix of shape (m, d)
        eps: Small constant for numerical stability

    Returns:
        Normalized matrix of shape (m, d).
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.