Computes and stores the average and current value.
| 42 | model.model.panoptic_on = value |
| 43 | |
| 44 | class AverageMeter(object): |
| 45 | """Computes and stores the average and current value.""" |
| 46 | def __init__(self): |
| 47 | self.reset() |
| 48 | |
| 49 | def reset(self): |
| 50 | self.val = 0 |
| 51 | self.avg = 0 |
| 52 | self.sum = 0 |
| 53 | self.count = 0 |
| 54 | |
| 55 | def update(self, val, n=1, decay=0): |
| 56 | self.val = val |
| 57 | if decay: |
| 58 | alpha = math.exp(-n / decay) # exponential decay over 100 updates |
| 59 | self.sum = alpha * self.sum + (1 - alpha) * val * n |
| 60 | self.count = alpha * self.count + (1 - alpha) * n |
| 61 | else: |
| 62 | self.sum += val * n |
| 63 | self.count += n |
| 64 | self.avg = self.sum / self.count |
nothing calls this directly
no outgoing calls
no test coverage detected