Correcting the training loop, but there is still an error