quaterion.loss.arcface_loss module

class ArcFaceLoss(embedding_size: int, num_groups: int, scale: float = 64.0, margin: float = 0.5)[source]

Bases: GroupLoss

Additive Angular Margin Loss as defined in

  • embedding_size – Output dimension of the encoder.

  • num_groups – Number of groups in the dataset.

  • scale – Scaling value to make cross entropy work.

  • margin – Margin value to push groups apart.

forward(embeddings: Tensor, groups: LongTensor) Tensor[source]

Compute loss value

  • embeddings – shape: (batch_size, vector_length) - Output embeddings from the encoder.

  • groups – shape: (batch_size,) - Group ids associated with embeddings.


Tensor – loss value.

training: bool


Learn more about Qdrant vector search project and ecosystem

Discover Qdrant

Similarity Learning

Explore practical problem solving with Similarity Learning

Learn Similarity Learning


Find people dealing with similar problems and get answers to your questions

Join Community