loss.data outputs a single value, as you’d expect, but it’s running_loss that’s being divided by 2000. By the time you reach that print statement, running_loss has added together 2000 loss values, so dividing by 2000 gives the average. Then running_loss is reset to zero and the process starts again.