[96354c]: / src / metrics / training_metrics.py

Download this file

22 lines (12 with data), 347 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def reset(self):
self.sum = 0
self.count = 0
def update(self, val, n=1):
self.sum += val * n
self.count += n
def avg(self):
return self.sum / self.count