Extract training functions

This commit is contained in:
Andras Schmelczer 2024-06-25 08:23:59 +01:00
commit d336ec3be6
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
4 changed files with 183 additions and 0 deletions

View file

@ -1,7 +0,0 @@
from pathlib import Path
def get_next_run_name(path: Path, prefix: str = "run") -> str:
run_ids = [int(run.stem.split("_")[1]) for run in path.glob(f"{prefix}_*")]
next_run_id = max(run_ids, default=-1) + 1
return f"{prefix}_{next_run_id}"

View file

@ -0,0 +1,5 @@
from typing import Any, Dict
def serialise_hparams(hyperparameters: Dict[str, Any]) -> Dict[str, Any]:
return {k: str(v) if isinstance(v, list) else v for k, v in hyperparameters.items()}