loss.item() will return a float that is the average of loss for all samples in your batch in a single iteration. If you want to average loss across all iterations or epochs, you have to implement a class that averages all your losses in iterations or epochs: something like this: examples/main.py at 2639cf050493df9d3cbf065d45e6025733add0f4 · pytorch/examples · GitHub 10