structure
structure¶
- class hanlp.common.structure.ConfigTracker(locals_: Dict, exclude=('kwargs', 'self', '__class__', 'locals_'))[source]¶
This base class helps sub-classes to capture their arguments passed to
__init__
, and also their types so that they can be deserialized from a config in dict form.- Parameters
locals – Obtained by
locals()
.exclude – Arguments to be excluded.
Examples
>>> class MyClass(ConfigTracker): >>> def __init__(self, i_need_this='yes') -> None: >>> super().__init__(locals()) >>> obj = MyClass() >>> print(obj.config) {'i_need_this': 'yes', 'classpath': 'test_config_tracker.MyClass'}
- class hanlp.common.structure.History[source]¶
A history of training context. It records how many steps have passed and provides methods to decide whether an update should be performed, and to caculate number of training steps given dataloader size and
gradient_accumulation
.