MultiLabelMarginLoss — PyTorch 1.10.1 documentation
pytorch.org › torchclass torch.nn.MultiLabelMarginLoss(size_average=None, reduce=None, reduction='mean') [source] Creates a criterion that optimizes a multi-class multi-classification hinge loss (margin-based loss) between input x x (a 2D mini-batch Tensor ) and output y y (which is a 2D Tensor of target class indices). For each sample in the mini-batch:
loss函数之MultiMarginLoss,...
blog.csdn.net › ltochange › articleJun 20, 2021 · MultiMarginLoss 多分类合页损失函数(hinge loss),对于一个样本不是考虑样本输出与真实类别之间的误差,而是考虑对应真实类别与其他类别之间的误差 对于包含 N 个样本的batch数据 D(x,y) , x 为神经网络的输出, y 是真实的类别标签,假设类别数为 C, 0 ≤ yn ≤ C −1 。 第 n 个样本的损失值 ln 计算如下: ln = C 1 i=0&i =yn ∑C−1 max(0,margin−xn [yn ]+ xn [i])p 为了处理多个类别之间的样本不平衡问题,对于每一类可传入相应的权值 w 。 ln = C 1 i=0&i =yn ∑C−1 max(0,w[yn ](margin−xn [yn ]+ xn [i]))p 若
MultiMarginLoss — PyTorch 1.10.1 documentation
pytorch.org › torchMultiMarginLoss class torch.nn.MultiMarginLoss(p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean') [source] Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x x (a 2D mini-batch Tensor) and output y y (which is a 1D tensor of target class indices,