n1i=1∑n∣yi−y^i∣ Pytorch: import torch.nn.functional as F F.l1_loss(y_pred, y_target) Also: (y_pred - y_target).abs().mean()