Unfinished Codes

This commit is contained in:
D-X-Y
2021-04-25 06:02:43 -07:00
parent 77c250c8fc
commit 89a5faabc3
4 changed files with 178 additions and 0 deletions

View File

@@ -1,3 +1,8 @@
#####################################################
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2020.04 #
#####################################################
import abc
def obtain_accuracy(output, target, topk=(1,)):
"""Computes the precision@k for the specified values of k"""
maxk = max(topk)
@@ -12,3 +17,12 @@ def obtain_accuracy(output, target, topk=(1,)):
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
res.append(correct_k.mul_(100.0 / batch_size))
return res
class EvaluationMetric(abc.ABC):
def __init__(self):
self._total_metrics = 0
def __len__(self):
return self._total_metrics