parsing¶
Functions
Removes all unpicklable entries from hparams. |
|
Recursively collects the arguments passed to the child constructors in the inheritance tree. |
|
For backwards compatibility: #16369. |
|
Tests if an object can be pickled. |
|
Special getattr for Lightning. |
|
Special hasattr for Lightning. |
|
Special setattr for Lightning. |
|
Parse key words for standard |
|
See |
Classes
Extended dictionary accessible with dot notation. |
Utilities used for parameter parsing.
- class lightning.pytorch.utilities.parsing.AttributeDict[소스]¶
기반 클래스:
Dict
Extended dictionary accessible with dot notation.
>>> ad = AttributeDict({'key1': 1, 'key2': 'abc'}) >>> ad.key1 1 >>> ad.update({'my-key': 3.14}) >>> ad.update(new_key=42) >>> ad.key1 = 2 >>> ad "key1": 2 "key2": abc "my-key": 3.14 "new_key": 42
- lightning.pytorch.utilities.parsing.clean_namespace(hparams)[소스]¶
Removes all unpicklable entries from hparams.
- 반환 형식
- lightning.pytorch.utilities.parsing.collect_init_args(frame, path_args, inside=False, classes=())[소스]¶
Recursively collects the arguments passed to the child constructors in the inheritance tree.
- 매개변수
frame¶ (
frame
) – the current stack framepath_args¶ (
List
[Dict
[str
,Any
]]) – a list of dictionaries containing the constructor args in all parent classesinside¶ (
bool
) – track if we are inside inheritance path, avoid terminating too soonclasses¶ (
Tuple
[Type
,...
]) – the classes in which to inspect the frames
- 반환 형식
- 반환
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.
- lightning.pytorch.utilities.parsing.lightning_getattr(model, attribute)[소스]¶
Special getattr for Lightning. Checks for attribute in model namespace, the old hparams namespace/dict, and the datamodule.
- 예외 발생
AttributeError – If
model
doesn’t haveattribute
in any of model namespace, the hparams namespace/dict, and the datamodule.- 반환 형식
- lightning.pytorch.utilities.parsing.lightning_hasattr(model, attribute)[소스]¶
Special hasattr for Lightning.
Checks for attribute in model namespace, the old hparams namespace/dict, and the datamodule.
- 반환 형식
- lightning.pytorch.utilities.parsing.lightning_setattr(model, attribute, value)[소스]¶
Special setattr for Lightning. Checks for attribute in model namespace and the old hparams namespace/dict. Will also set the attribute on datamodule, if it exists.
- 예외 발생
AttributeError – If
model
doesn’t haveattribute
in any of model namespace, the hparams namespace/dict, and the datamodule.- 반환 형식