MCPcopy Index your code
hub / github.com/geekcomputers/Python / update

Method update

ML/src/python/neuralforge/utils/metrics.py:11–22  ·  view source on GitHub ↗
(self, metrics: Dict[str, Any])

Source from the content-addressed store, hash-verified

9 self.best_metrics = {}
10
11 def update(self, metrics: Dict[str, Any]):
12 self.metrics.append(metrics.copy())
13
14 for key, value in metrics.items():
15 if isinstance(value, (int, float)):
16 if key not in self.best_metrics:
17 self.best_metrics[key] = value
18 else:
19 if 'loss' in key.lower():
20 self.best_metrics[key] = min(self.best_metrics[key], value)
21 else:
22 self.best_metrics[key] = max(self.best_metrics[key], value)
23
24 def get_history(self, key: str) -> List[Any]:
25 return [m.get(key) for m in self.metrics if key in m]

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected