vis4d.op.loss.embedding_distance¶
Embedding distance loss.
Classes
|
Embedding distance loss for learning appearance similarity. |
- class EmbeddingDistanceLoss(reducer=<function identity_loss>, neg_pos_ub=3.0, pos_margin=0.0, neg_margin=0.3, hard_mining=True)[source]¶
Embedding distance loss for learning appearance similarity.
Computes the difference between the target distances and the predicted distances of two sets of embedding vectors. Uses hard negative mining based on the loss values to select pairs for overall loss computation.
Creates an instance of the class.
- forward(pred, target, weight=None)[source]¶
Forward function.
- Parameters:
pred (torch.Tensor) – The predicted distances between two sets of predictions. Shape [N, M].
target (torch.Tensor) – The corresponding target distances. Either zero (different identity) or one (same identity).
weight (torch.Tensor, optional) – The weight of loss for each prediction. Defaults to None.
- Returns:
embedding distance loss.
- Return type:
loss_bbox (torch.Tensor)