class
MultiLabelMarginLoss
extends
MultilabelMarginLossMultiLabelMarginLoss(reduction: str = 'mean')CamelCase alias for MultilabelMarginLoss.
Provided so that nn.MultiLabelMarginLoss (the capitalisation used
by the reference framework) resolves to the same implementation.
There is no behavioural difference — all parameters, attributes, and
shapes are identical to MultilabelMarginLoss.
Parameters
reductionstr= 'mean''none' | 'mean' (default) | 'sum'.Notes
Identical loss formula to MultilabelMarginLoss:
where the sum is taken over all pairs such that . Targets are padded with to mark end-of-list; entries at or beyond the first are ignored.
Examples
Interchangeable with :class:`MultilabelMarginLoss`:
>>> import lucid
>>> import lucid.nn as nn
>>> criterion = nn.MultiLabelMarginLoss()
>>> scores = lucid.tensor([[0.5, 0.2, 0.9, 0.1]])
>>> target = lucid.tensor([[2, 0, -1, -1]])
>>> loss = criterion(scores, target)
Verifying alias equivalence:
>>> import lucid.nn as nn
>>> assert nn.MultiLabelMarginLoss is nn.MultiLabelMarginLoss
>>> c1 = nn.MultilabelMarginLoss()
>>> c2 = nn.MultiLabelMarginLoss()
>>> # Both produce identical results for the same inputs.