MCPcopy
hub / github.com/PaddlePaddle/PaddleOCR / TrainingStats

Class TrainingStats

ppocr/utils/stats.py:41–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41class TrainingStats(object):
42 def __init__(self, window_size, stats_keys):
43 self.window_size = window_size
44 self.smoothed_losses_and_metrics = {
45 key: SmoothedValue(window_size) for key in stats_keys
46 }
47
48 def update(self, stats):
49 for k, v in stats.items():
50 if k not in self.smoothed_losses_and_metrics:
51 self.smoothed_losses_and_metrics[k] = SmoothedValue(self.window_size)
52 self.smoothed_losses_and_metrics[k].add_value(v)
53
54 def get(self, extras=None):
55 stats = collections.OrderedDict()
56 if extras:
57 for k, v in extras.items():
58 stats[k] = v
59 for k, v in self.smoothed_losses_and_metrics.items():
60 stats[k] = round(v.get_median_value(), 6)
61
62 return stats
63
64 def log(self, extras=None):
65 d = self.get(extras)
66 strs = []
67 for k, v in d.items():
68 strs.append("{}: {:x<6f}".format(k, v))
69 strs = ", ".join(strs)
70 return strs

Callers 1

trainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…