pytorch_lightning.utilities.parsing module¶
-
class
pytorch_lightning.utilities.parsing.
AttributeDict
[source]¶ Bases:
dict
Extended dictionary accesisable with dot notation.
>>> ad = AttributeDict({'key1': 1, 'key2': 'abc'}) >>> ad.key1 1 >>> ad.update({'my-key': 3.14}) >>> ad.update(mew_key=42) >>> ad.key1 = 2 >>> ad "key1": 2 "key2": abc "mew_key": 42 "my-key": 3.14
-
pytorch_lightning.utilities.parsing.
clean_namespace
(hparams)[source]¶ Removes all functions from hparams so we can pickle.
-
pytorch_lightning.utilities.parsing.
collect_init_args
(frame, path_args, inside=False)[source]¶ Recursively collects the arguments passed to the child constructors in the inheritance tree.
- Parameters
- Return type
- Returns
A list of dictionaries where each dictionary contains the arguments passed to the constructor at that level. The last entry corresponds to the constructor call of the most specific class in the hierarchy.
-
pytorch_lightning.utilities.parsing.
str_to_bool
(val)[source]¶ Convert a string representation of truth to true (1) or false (0). Copied from the python implementation distutils.utils.strtobool
True values are ‘y’, ‘yes’, ‘t’, ‘true’, ‘on’, and ‘1’; false values are ‘n’, ‘no’, ‘f’, ‘false’, ‘off’, and ‘0’. Raises ValueError if ‘val’ is anything else.
>>> str_to_bool('YES') 1 >>> str_to_bool('FALSE') 0