profile pic
⌘ '
raccourcis clavier

see also: unstable docs

MultiMarginLoss

Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input xx (a 2D mini-batch Tensor) and output yy (which is a 1D tensor of target class indices, 0yx.size(1)10 \le y \le \text{x}.\text{size}(1) -1):

For each mini-batch sample, loss in terms of 1D input xx and output yy is:

loss(x,y)=imax0,marginx[y]+x[i]px.size(0)i{0,x.size(0)1} and iy\text{loss}(x,y) = \frac{\sum_{i} \max{0, \text{margin} - x[y] + x[i]}^p}{x.\text{size}(0)} \\ \because i \in \{0, \ldots x.\text{size}(0)-1\} \text{ and } i \neq y