MCPcopy Create free account
hub / github.com/SLDGroup/EMCAD / AvgMeter

Class AvgMeter

utils/utils.py:49–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 param_group['lr'] *= decay
48
49class AvgMeter(object):
50 def __init__(self, num=40):
51 self.num = num
52 self.reset()
53
54 def reset(self):
55 self.val = 0
56 self.avg = 0
57 self.sum = 0
58 self.count = 0
59 self.losses = []
60
61 def update(self, val, n=1):
62 self.val = val
63 self.sum += val * n
64 self.count += n
65 self.avg = self.sum / self.count
66 self.losses.append(val)
67
68 def show(self):
69 return torch.mean(torch.stack(self.losses[np.maximum(len(self.losses)-self.num, 0):]))
70
71def CalParams(model, input_tensor):
72 """

Callers 1

trainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected