neuraltrain.metrics.metrics.TopkAccFromScores

class neuraltrain.metrics.metrics.TopkAccFromScores(topk: int = 5, true_labels: Literal['first', 'diagonal'] = 'first')[source][source]

Top-k accuracy computed from already available similarity scores.

Parameters:
  • topk – K in top-k, i.e. minimal rank to classify a prediction as a success.

  • true_labels – Defines where to look for the scores of true pairs. If “first”, use the scores in the first column of the scores matrix; if “diagonal”, use the scores on the diagonal.

update(scores: Tensor) None[source][source]

Update internal list of ranks.