Shortcuts

quaterion.loss.fast_ap_loss module

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

Bases: GroupLoss

FastAP Loss

Adaptation from https://github.com/kunhe/FastAP-metric-learning.

Further information:

https://cs-people.bu.edu/fcakir/papers/fastap_cvpr2019.pdf. “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

Parameters:

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.

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.

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

Config used in saving and loading purposes.

Config object has to be JSON-serializable.

Returns:

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

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