CosineEmbeddingLossΒΆ

Creates a criterion that measures the loss given input tensors x1, x2 and a Tensor label y.

Abstract Signature:

CosineEmbeddingLoss(input1: Tensor, input2: Tensor, target: Tensor, margin: float = 0.0, reduction: str = mean)

PyTorch

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

JAX (Core)

API: optax.cosine_similarity_loss
Strategy: Plugin (loss_wrapper)