MCPcopy Create free account
hub / github.com/ChunmingHe/WS-SAM / AvgMeter

Class AvgMeter

utils/utils.py:61–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60
61class AvgMeter(object):
62 def __init__(self, num=40):
63 self.num = num
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 self.losses = []
72
73 def update(self, val, n=1):
74 self.val = val
75 self.sum += val * n
76 self.count += n
77 self.avg = self.sum / self.count
78 self.losses.append(val)
79
80 def show(self):
81 return torch.mean(torch.stack(self.losses[np.maximum(len(self.losses)-self.num, 0):]))
82
83
84def CalParams(model, input_tensor):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected