TorchMetrics documentation — PyTorch-Metrics 0.7.0 documentation
torchmetrics.readthedocs.io › en › stableimport torch import torchmetrics # initialize metric metric = torchmetrics. Accuracy () n_batches = 10 for i in range ( n_batches ): # simulate a classification problem preds = torch . randn ( 10 , 5 ) . softmax ( dim =- 1 ) target = torch . randint ( 5 , ( 10 ,)) # metric on current batch acc = metric ( preds , target ) print ( f "Accuracy on batch { i } : { acc } " ) # metric on all batches using custom accumulation acc = metric . compute () print ( f "Accuracy on all data: { acc } " )
Accuracy — PyTorch-Ignite v0.4.8 Documentation
pytorch.org › igniteAccuracy = T P + T N T P + T N + F P + F N \text{Accuracy} = \frac{ TP + TN }{ TP + TN + FP + FN } Accuracy = TP + TN + FP + FN TP + TN where TP \text{TP} TP is true positives, TN \text{TN} TN is true negatives, FP \text{FP} FP is false positives and FN \text{FN} FN is false negatives.