Skip to content

Rectify docs for MultiLabelSoftMarginLoss #36217

@andy-yangz

Description

@andy-yangz

📚 Documentation

Concern about MultiLabelSoftMarginLoss, I think there is still a problem with its doc.
As @DNGros pointed out, there is a lot of confusion when using MultiLabelMarginLoss and MultiLabelSoftMarginLoss, and he improved the docs. #15863
However, for the docs of MultiLabelSoftMarginLoss it's still not correct.
Since if you set the label as the docs

Target: (N, C)(N,C) , label targets padded by -1 ensuring same shape as the input.

pad it like [0,3,-1,-1], the result will be wrong.
If we look at the equation
image
we will find it, in fact, write clearly that label y need to be 0 or 1.
If we feed the -1 padded label, the loss actually sometimes will become negative number, and this is shown by my experiment.

So I think the right Target format for MultiLabelSoftMarginLoss is just one_hot vector.
And we can give a good example code as MultiLabelMarginLoss has.

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: docsRelated to our documentation, both in docs/ and docblocksmodule: nnRelated to torch.nntriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions