MCPcopy Index your code
hub / github.com/OpenGVLab/InternVL / MyAverageMeter

Class MyAverageMeter

classification/utils.py:387–408  ·  view source on GitHub ↗

Computes and stores the average and current value.

Source from the content-addressed store, hash-verified

385
386
387class MyAverageMeter(object):
388 """Computes and stores the average and current value."""
389
390 def __init__(self, max_len=-1):
391 self.val_list = []
392 self.count = []
393 self.max_len = max_len
394 self.val = 0
395 self.avg = 0
396 self.var = 0
397
398 def update(self, val):
399 self.val = val
400 self.avg = 0
401 self.var = 0
402 if not math.isnan(val) and not math.isinf(val):
403 self.val_list.append(val)
404 if self.max_len > 0 and len(self.val_list) > self.max_len:
405 self.val_list = self.val_list[-self.max_len:]
406 if len(self.val_list) > 0:
407 self.avg = np.mean(np.array(self.val_list))
408 self.var = np.std(np.array(self.val_list))

Callers 2

train_epochFunction · 0.90
train_one_epochFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected