Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli committed Apr 12, 2024
1 parent 35d7ee4 commit db50550
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions litgpt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,17 @@ def CLI(*args: Any, **kwargs: Any) -> Any:
return CLI(*args, **kwargs)


def capture_hparams():
def capture_hparams() -> Dict[str, Any]:
"""Captures the local variables ('hyperparameters') from where this function gets called."""
caller_frame = inspect.currentframe().f_back
locals_of_caller = caller_frame.f_locals
hparams = {}
for name, value in locals_of_caller.items():
if isinstance(value, (int, float, str, bool, Path)):
if value is None or isinstance(value, (int, float, str, bool, Path)):
hparams[name] = value
if is_dataclass(value):
hparams[name] = asdict(value)
return hparams


def save_hyperparameters(function: callable, checkpoint_dir: Path) -> None:
Expand Down

0 comments on commit db50550

Please sign in to comment.