Module neuralops.experiment_logging.tracker
Simple in‑memory metrics tracker with JSON serialisation.
Classes
class MetricsTracker (save_path: str | None = None)-
Expand source code
class MetricsTracker: """Collects metrics during training and saves them as JSON.""" def __init__(self, save_path: str | None = None) -> None: self.save_path = save_path self.records: list[dict[str, Any]] = [] def log(self, metrics: dict[str, Any], step: int = None) -> None: """Log.""" entry = dict(metrics) if step is not None: entry["step"] = step self.records.append(entry) def to_dataframe(self) -> Any: """To dataframe.""" import pandas as pd return pd.DataFrame(self.records) def save(self, path: str | None = None) -> None: """Save.""" p = path or self.save_path if p: os.makedirs(os.path.dirname(p), exist_ok=True) with open(p, "w") as f: json.dump(self.records, f, indent=2) def flush(self) -> None: """Flush.""" if self.save_path: self.save(self.save_path)Collects metrics during training and saves them as JSON.
Methods
def flush(self) ‑> None-
Expand source code
def flush(self) -> None: """Flush.""" if self.save_path: self.save(self.save_path)Flush.
def log(self, metrics: dict[str, typing.Any], step: int = None) ‑> None-
Expand source code
def log(self, metrics: dict[str, Any], step: int = None) -> None: """Log.""" entry = dict(metrics) if step is not None: entry["step"] = step self.records.append(entry)Log.
def save(self, path: str | None = None) ‑> None-
Expand source code
def save(self, path: str | None = None) -> None: """Save.""" p = path or self.save_path if p: os.makedirs(os.path.dirname(p), exist_ok=True) with open(p, "w") as f: json.dump(self.records, f, indent=2)Save.
def to_dataframe(self) ‑> Any-
Expand source code
def to_dataframe(self) -> Any: """To dataframe.""" import pandas as pd return pd.DataFrame(self.records)To dataframe.