Computes and stores the average and current value
| 4 | |
| 5 | |
| 6 | class AverageMeter(object): |
| 7 | """Computes and stores the average and current value""" |
| 8 | def __init__(self): |
| 9 | self.reset() |
| 10 | |
| 11 | def reset(self): |
| 12 | self.val = 0 |
| 13 | self.avg = 0 |
| 14 | self.sum = 0 |
| 15 | self.count = 0 |
| 16 | |
| 17 | def update(self, val, n=1): |
| 18 | self.val = val |
| 19 | self.sum += val * n |
| 20 | self.count += n |
| 21 | self.avg = self.sum / self.count |
| 22 | |
| 23 | |
| 24 | def accuracy(output, target, topk=(1,)): |
no outgoing calls
no test coverage detected