This MR is an extension to MR !188 (merged), that addressed issue #472 (closed) about implementing a new 'Model' abstraction layer and refactoring framework-specific code from the current 'TrainingPlan' classes into it and its framework- or model-specific subclasses.
This MR implements the following changes:
- Disambiguate class attributes from instance attributes in 'Model' and its subclasses.
- Declare instance attributes as part of
__init__
methods and class attributes at the proper scope. - Use the
ClassVar
type-hint to further highlight that some attributes are defined at class level.
- Declare instance attributes as part of
- Add
Model._model_type
private class attribute and use it for init-type type-checking.- This class attribute enables specifying what classes of models may be wrapped.
- It was used to refactor type-checking code into the shared parent
Model.__init__
.
- Revise 'Model.get_weights' and 'Model.get_gradients' signatures.
- Replace the generic
return_type
attribute withas_vector: bool = False
. - This was done in accordance with @scansiz, with issue #481 (closed) in mind.
- Replace the generic
- Revise
BaseSkLearnModel.train
backend and remove superfluous private attributes. - Revise
TorchModel.init_params
.- Previously, the signature and actual type of this attribute did not match.
- Perform an overall cleaning of import statements' ordering, type hints and code formatting.
- Rename scikit-learn backend
Models
dict toSKLEARN_MODELS
out of PEP-8 compliance.