pytorch-损失函数

Loss Function

pytorch中常用的损失函数

损失函数 名称 适用场景 说明
torch.nn.MSELoss() 均方误差损失 回归 取预测值和真实值的绝对误差的平均数 $$ℓ(x,y) = {1 \over N} \sum_{n}^{N}|x_n​−y_n|$$
torch.nn.L1Loss() 平均绝对值误差损失 回归
torch.nn.CrossEntropyLoss() 交叉熵损失 多分类
torch.nn.NLLLoss() 负对数似然函数损失 多分类
torch.nn.NLLLoss2d() 图片负对数似然函数损失 图像分割
torch.nn.KLDivLoss() KL散度损失 回归
torch.nn.BCELoss() 二分类交叉熵损失 二分类
torch.nn.MarginRankingLoss() 评价相似度的损失
torch.nn.MultiLabelMarginLoss() 多标签分类的损失 多标签分类
torch.nn.SmoothL1Loss() 平滑的L1损失 回归 也叫作 Huber Loss,误差在 (-1,1) 上是平方损失,其他情况是 L1 损失,应用于回归。
torch.nn.SoftMarginLoss() 多标签二分类问题的损失 多标签二分类
-------------本文结束感谢您的阅读-------------