It seems you are multiplying by the batch size, which would thus accumulate the loss of all samples in avg_loss.
If that’s the case, you should divide by the number of samples to get the average loss, bot the length of the DataLoader, which will return the number of batches.