Skip to content

Commit

Permalink
accuracy function
Browse files Browse the repository at this point in the history
  • Loading branch information
yongqyu committed Feb 23, 2019
1 parent 85f74ab commit e801923
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions metric.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import torch
from sklearn.metrics import accuracy_score

def accuracy(preds, target):
preds = torch.max(preds, 1)[1].float()
acc = accuracy_score(preds.cpu().numpy(), target.cpu().numpy())

return acc

0 comments on commit e801923

Please sign in to comment.