TorchedUp
ProblemsPremium
TorchedUp
L2 RegularizationEasy
ProblemsPremium

L2 Regularization

Implement the L2 regularization penalty term.

Signature: def l2_reg(w: np.ndarray, lam: float) -> float

Return lam * sum(w^2).

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○basic
○zero weights
○large lambda🔒 Premium
○L2 penalty is non-negative
○L2 penalty is non-negative (negative weights only)
○L2 invariant to sign of weights
Advertisement