running_loss += loss.item(),pytorch中的item()

item()返回loss的值,叠加之后算出总loss,最后再除以mini-batches的数量,取loss平均值。

你可能感兴趣的:(pycharm/dl,python,深度学习)