Implement Mean Squared Error Loss
0
In this exercise, you are required to manually compute the Mean Squared Error (MSE) loss between two tensors, representing predicted values and actual values, respectively. The MSE is calculated as the average of the squared differences between corresponding elements in the two tensors. The solution should support tensors of any dimensionality, as long as the input_tensor and target_tensor have the same shape.
Where:
- : Each individual actual data point.
- : Each individual predicted data point.
- : Mean Squared Error between the actual and predicted data points.
- : Total number of data points.
Examples:
1.0
2.0
3.0
1.0
2.5
2.5
↓
0.1666666716337204
3.0
-3.0
0.0
1
0
0
3.0
-2.5
0.5
1
-1
1
↓
0.4166666567325592
Loading...