Compute the training error on the way to compute the objective value.