TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

5. MSE Loss

Easy

Implement Mean Squared Error loss.

Signature: def mse_loss(y_pred: np.ndarray, y_true: np.ndarray) -> float

Math

LMSE​=n1​i=1∑n​(y^​i​−yi​)2

Related problems

  • MSE Loss (PyTorch)easyPyTorch

Asked at

Python 30/10 runs today

Output

Anything you print() in your code will show up here after you click Run.

Test Results

○perfect
○typical
○large error🔒 Premium
○loss is non-negative
○loss is non-negative (negative residuals)
○symmetric: mse(a,b) == mse(b,a)
○symmetric (swapped): mse(b,a) == mse(a,b)
○2D batch (B=2, D=3) — must normalize over all elements (mean), not sum/B🔒 Premium