lmp.util.cfg#

Save and load training configurations.

lmp.util.cfg.load(exp_name: str) Namespace[source]#

Load training configuration from JSON file.

Load training configuration from path project_root/exp/exp_name/cfg.json.

Parameters

exp_name (str) – Name of the training experiment.

Returns

Training experiment’s configurations. Returned configurations are wrapped in argparse.Namespace for convenience.

Return type

argparse.Namespace

See also

save

Save training configurations into JSON file.

Examples

>>> import argparse
>>> import lmp.util.cfg
>>> args = argparse.Namespace(a=1, b=2, c=3)
>>> lmp.util.cfg.save(args=args, exp_name='my_exp')
>>> assert args == lmp.util.cfg.load(exp_name='my_exp')
lmp.util.cfg.save(args: Namespace, exp_name: str) None[source]#

Save training configurations into JSON file.

Save training configuration under the path project_root/exp/exp_name/cfg.json. All CLI arguments parsed by scripts are saved. If folders along the saving path do not exist, then this method will create folders recursively.

Danger

This method overwrite existing files. Make sure you know what you are doing before calling this method.

Parameters
  • args (argparse.Namespace) – Parsed CLI arguments which will be saved.

  • exp_name (str) – Name of the training experiment.

Return type

None

See also

load

Load training configurations from JSON file.

Examples

>>> import argparse
>>> import lmp.util.cfg
>>> args = argparse.Namespace(a=1, b=2, c=3)
>>> lmp.util.cfg.save(args=args, exp_name='my_exp')
>>> assert args == lmp.util.cfg.load(exp_name='my_exp')