Skip to content

← Loss Functions step 1 of 8

Easy Primitives

Implement Mean Squared Error

Implement the Mean Squared Error (MSE) loss function.

$$\text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2$$

Input: Two 1D tensors y_true and y_pred of the same shape

Output: A scalar tensor representing the mean squared error

Loading visualization…