Squared loss measures prediction error by squaring the difference between each prediction and its target. Averaging these squared differences produces one loss value for training. section 3.3.2
Training a linear classifier
A linear classifier predicts two-dimensional points with prediction = matmul(input, W) + b. On 2,000 synthetic points from two classes, minimizing squared loss with batch gradient updates reduces the loss from 4.5364 to 0.0289 over 40 steps. Predictions above 0.5 separate the classes. section 3.3.2
mean_squared_error <- function(targets, predictions) {
per_sample_losses <- tf$square(targets - predictions) #1
tf$reduce_mean(per_sample_losses) #2
}
The implementation squares elementwise target-prediction differences, then averages the per-sample losses. section 3.3.2



