I am working on calculating the top k accuracy of a model my model output logits (I am working on pythorch) so in order to calculate the top k accuracy using sklearn i was wondering what would be the difeerence if I calculate the top k accuracy using the logits vs the softmax probabilites ?

Thanks in advance


1 Answer 1


The accuracies will be the same. Softmax is a monotonic increasing function, so the argmax on the logit scale is the same as the argmax on the probability scale. Likewise, the top $k$ entries will be the same.

  • $\begingroup$ top_k_accuracy_score(y_true, y_score, k=2) this is the top k accuracy of sklearn but what I find in their example y_score never some up to 1 ? what y_score could be ? a softmax ? scikit-learn.org/stable/modules/generated/… $\endgroup$
    – oubo21
    Feb 13, 2022 at 23:45
  • 2
    $\begingroup$ It sounds like you have another question, but the new question is about software. Software questions are not on-topic here, as described in the help center. $\endgroup$
    – Sycorax
    Feb 13, 2022 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.