neuraltrain.metrics.metrics.Rank¶
- class neuraltrain.metrics.metrics.Rank(reduction: Literal['mean', 'median', 'std'] = 'median', relative: bool = False, torchmetrics_kwargs: dict[str, Any] | None = None)[source][source]¶
Rank of predictions based on a retrieval set, using cosine similarity.
- Parameters:
- compute() Tensor[source][source]¶
Override this method to compute the final metric value.
This method will automatically synchronize state variables when running in distributed backend.
- update(x: Tensor, y: Tensor, x_labels: None | list[str] = None, y_labels: None | list[str] = None) None[source][source]¶
Update internal list of ranks.
- Parameters:
x – Tensor of predictions, of shape (N, F).
y – Tensor of retrieval set examples, of shape (M, F).
x_labels – If provided, used to match predictions and ground truths that don’t have the same number of examples. Should have length of N and M, respectively
y_labels – If provided, used to match predictions and ground truths that don’t have the same number of examples. Should have length of N and M, respectively