Computes and stores the average and current value
| 6 | from lib.model.DSTformer import DSTformer |
| 7 | |
| 8 | class AverageMeter(object): |
| 9 | """Computes and stores the average and current value""" |
| 10 | def __init__(self): |
| 11 | self.reset() |
| 12 | |
| 13 | def reset(self): |
| 14 | self.val = 0 |
| 15 | self.avg = 0 |
| 16 | self.sum = 0 |
| 17 | self.count = 0 |
| 18 | |
| 19 | def update(self, val, n=1): |
| 20 | self.val = val |
| 21 | self.sum += val * n |
| 22 | self.count += n |
| 23 | self.avg = self.sum / self.count |
| 24 | |
| 25 | def accuracy(output, target, topk=(1,)): |
| 26 | """Computes the accuracy over the k top predictions for the specified values of k""" |
no outgoing calls
no test coverage detected