quaterion.loss.fast_ap_loss module

class FastAPLoss(num_bins: int | None = 10)[source]

Bases: GroupLoss

FastAP Loss

Adaptation from

Further information: “Deep Metric Learning to Rank” Fatih Cakir(*), Kun He(*), Xide Xia, Brian Kulis, and Stan Sclaroff IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019


num_bins – The number of soft histogram bins for calculating average precision. The paper suggests using 10.

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

Compute loss value.

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

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


Tensor – Scalar loss value.

get_config_dict() Dict[str, Any][source]

Config used in saving and loading purposes.

Config object has to be JSON-serializable.


Dict[str, Any] – JSON-serializable dict of params

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