FunctionRacerProblemsRace

How Often Right

MediumPyTorchPython

logits has one row per example and one column per class. The predicted class of an example is the column with its highest score. labels holds the right classes. Return the accuracy: the share of examples predicted right, from 0 to 1.

Example 1

logits [[0.1,0.9],[0.8,0.2],[0.3,0.7]]
labels [1,0,0]
returns 0.6666667

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems