MCPcopy
hub / github.com/HobbitLong/SupContrast / AverageMeter

Class AverageMeter

util.py:18–33  ·  view source on GitHub ↗

Computes and stores the average and current value

Source from the content-addressed store, hash-verified

16
17
18class AverageMeter(object):
19 """Computes and stores the average and current value"""
20 def __init__(self):
21 self.reset()
22
23 def reset(self):
24 self.val = 0
25 self.avg = 0
26 self.sum = 0
27 self.count = 0
28
29 def update(self, val, n=1):
30 self.val = val
31 self.sum += val * n
32 self.count += n
33 self.avg = self.sum / self.count
34
35
36def accuracy(output, target, topk=(1,)):

Callers 5

trainFunction · 0.90
validateFunction · 0.90
trainFunction · 0.90
trainFunction · 0.90
validateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected