torch.nn.functional.multi_margin_loss
-
torch.nn.functional.multi_margin_loss(input, target, p=1, margin=1.0, weight=None, size_average=None, reduce=None, reduction='mean')[source] -
Compute the multi margin loss, with optional weighting.
See
MultiMarginLossfor details.- Parameters
-
- input (Tensor) – Predicted values.
- target (Tensor) – Ground truth values.
- p (int, optional) – Has a default value of 1. 1 and 2 are the only supported values.
- margin (float, optional) – Margin for multi margin loss. Has a default value of 1.
- weight (Tensor, optional) – Weights for each sample. Default: None.
-
size_average (bool, optional) – Deprecated (see
reduction). -
reduce (bool, optional) – Deprecated (see
reduction). - reduction (str, optional) – Specifies the reduction to apply to the output: ‘none’ | ‘mean’ | ‘sum’. ‘mean’: the mean of the output is taken. ‘sum’: the output will be summed. ‘none’: no reduction will be applied. Default: ‘mean’.
- Returns
-
Multi margin loss (optionally weighted).
- Return type