Shortcuts

quaterion.loss.circle_loss module

class CircleLoss(margin: float | None = 0.25, scale_factor: float | None = 256, distance_metric_name: Distance | None = Distance.COSINE)[source]

Bases: GroupLoss

Implements Circle Loss as defined in https://arxiv.org/abs/2002.10857.

Parameters:
  • margin – Margin value to push negative examples.

  • scale_factor – scale factor γ determines the largest scale of each similarity score.

Note

Refer to sections 4.1 and 4.5 in the paper for default values and evaluation of margin and scaling_factor hyperparameters.

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

Compute loss value.

Parameters:
  • embeddings – shape: (batch_size, vector_length) - Batch of embeddings.

  • groups – shape: (batch_size,) - Batch of labels associated with embeddings

Returns:

Tensor – Scalar loss value.

training: bool

Qdrant

Learn more about Qdrant vector search project and ecosystem

Discover Qdrant

Similarity Learning

Explore practical problem solving with Similarity Learning

Learn Similarity Learning

Community

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

Join Community