Computes and stores the average and current value Imported from https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262
| 57 | raise |
| 58 | |
| 59 | class AverageMeter(object): |
| 60 | """Computes and stores the average and current value |
| 61 | Imported from https://github.com/pytorch/examples/blob/master/imagenet/main.py#L247-L262 |
| 62 | """ |
| 63 | def __init__(self): |
| 64 | self.reset() |
| 65 | |
| 66 | def reset(self): |
| 67 | self.val = 0 |
| 68 | self.avg = 0 |
| 69 | self.sum = 0 |
| 70 | self.count = 0 |
| 71 | |
| 72 | def update(self, val, n=1): |
| 73 | self.val = val |
| 74 | self.sum += val * n |
| 75 | self.count += n |
| 76 | self.avg = self.sum / self.count |
| 77 | |
| 78 | |
| 79 | class Cycle(object): |
no outgoing calls