Hi Fancy!



 fancy:

Is that really the way to go with pyTorch?


Yes.  Pytorch does not offer a general-purpose training-loop function.
I think the issue is that for the most basic use case the training loop
is quite simple and hardly a bother to write by hand.  But there are
lots of different things you might want to do in a training loop as you
move beyond the most basic use case so designing a general-purpose
training-loop function becomes messy.
The training loop typically loops over epochs as well as batches.
Do you want to calculate one or more accuracy measures?  Do
you want to do so periodically after every n batches or n epochs?
Do you want to periodically calculate losses or accuracies for a
validation set?  Do you want to implement early stopping based on
some validation measure?  Are you collecting statistics or printing out
progress messages as you train?  Are you training multiple networks
with the same batches or training an adversarial network?
These – and more – are some of the features a pre-packaged
training-loop function might be asked to support.  Which would
you implement?  What would the interface to function look like?
Good luck.
K. Frank