Hi everyone,

I’m trying to use torch.nn.MultiLabelMarginLoss as a 1999 multiclass text classification proble. However, the docs really confuses me.

The docs is below:

Creates a criterion that optimizes a multi-class multi-classification hinge loss (margin-based loss) between input x (a 2D mini-batch Tensor) and output y (which is a 2D Tensor of target class indices). For each sample in the mini-batch:

loss(x, y) = sum_ij(max(0, 1 - (x[y[j]] - x[i]))) / x.size(0)

where i == 0 to x.size(0), j == 0 to y.size(0), y[j] != 0, and i != y[j] for all i and j.

y and x must have the same size.

The criterion only considers the first non zero y[j] targets.

This allows for different samples to have variable amounts of target classes

Could anyone tell me what’s the appropriate y in the argument when a sample is tagged as classes (1,100,200)?