torch.nn.modules.loss — PyTorch 1.10.1 documentation
pytorch.org › _modules › torchThe loss function then becomes:.. math:: \text{loss}(x, y) = \frac{\sum_i \max(0, w[y] * (\text{margin} - x[y] + x[i]))^p}{\text{x.size}(0)} Args: p (int, optional): Has a default value of :math:`1`. :math:`1` and :math:`2` are the only supported values. margin (float, optional): Has a default value of :math:`1`. weight (Tensor, optional): a ...
TripletMarginWithDistanceLoss — PyTorch 1.10.1 documentation
https://pytorch.org/.../torch.nn.TripletMarginWithDistanceLoss.htmlTripletMarginWithDistanceLoss¶ class torch.nn. TripletMarginWithDistanceLoss (*, distance_function = None, margin = 1.0, swap = False, reduction = 'mean') [source] ¶. Creates a criterion that measures the triplet loss given input tensors a a a, p p p, and n n n (representing anchor, positive, and negative examples, respectively), and a nonnegative, real-valued function …
MultiMarginLoss — PyTorch 1.10.1 documentation
pytorch.org › torchMultiMarginLoss (p = 1, margin = 1.0, weight = None, size_average = None, reduce = None, reduction = 'mean') [source] ¶ Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between input x x x (a 2D mini-batch Tensor ) and output y y y (which is a 1D tensor of target class indices, 0 ≤ y ≤ x.size ...
TripletMarginLoss — PyTorch 1.10.1 documentation
pytorch.org › torchTripletMarginLoss (margin = 1.0, p = 2.0, eps = 1e-06, swap = False, size_average = None, reduce = None, reduction = 'mean') [source] ¶ Creates a criterion that measures the triplet loss given an input tensors x 1 x1 x 1, x 2 x2 x 2, x 3 x3 x 3 and a margin with a value greater than 0 0 0. This is used for measuring a relative similarity ...
MarginRankingLoss — PyTorch 1.10.1 documentation
pytorch.org › torchMarginRankingLoss (margin = 0.0, size_average = None, reduce = None, reduction = 'mean') [source] ¶ Creates a criterion that measures the loss given inputs x 1 x1 x 1 , x 2 x2 x 2 , two 1D mini-batch Tensors , and a label 1D mini-batch tensor y y y (containing 1 or -1).