MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / AverageMeter

Class AverageMeter

utils/misc.py:44–64  ·  view source on GitHub ↗

Computes and stores the average and current value.

Source from the content-addressed store, hash-verified

42 model.model.panoptic_on = value
43
44class 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected