TripletMarginLossΒΆ

Creates a criterion that measures the triplet loss.

Abstract Signature:

TripletMarginLoss(anchor: Tensor, positive: Tensor, negative: Tensor, margin: float = 1.0, p: float = 2.0, eps: float = 1e-06, swap: bool = False)

PyTorch

API: torch.nn.functional.triplet_margin_loss
Strategy: Direct Mapping

JAX (Core)

API: β€”
Strategy: Plugin (triplet_loss_impl)

TensorFlow

API: tf.keras.losses.triplet_semihard_loss
Strategy: Macro 'tf.maximum(tf.norm({anchor}-{positive}, ord={p}) - tf.norm({anchor}-{negative}, ord={p}) + {margin}, 0)'