deeppavlov.core.models¶
Abstract model classes and interfaces.
-
class
deeppavlov.core.models.component.
Component
[source]¶ Abstract class for all callables that could be used in Chainer’s pipe.
-
class
deeppavlov.core.models.serializable.
Serializable
(save_path: Optional[Union[pathlib.Path, str]], load_path: Optional[Union[pathlib.Path, str]] = None, mode: str = 'infer', *args, **kwargs)[source]¶ Abstract base class that expresses the interface for all models that can serialize data to a path.
-
class
deeppavlov.core.models.estimator.
Estimator
(save_path: Optional[Union[pathlib.Path, str]], load_path: Optional[Union[pathlib.Path, str]] = None, mode: str = 'infer', *args, **kwargs)[source]¶ Abstract class for components that could be fitted on the data as a whole.
-
class
deeppavlov.core.models.nn_model.
NNModel
(save_path: Optional[Union[pathlib.Path, str]], load_path: Optional[Union[pathlib.Path, str]] = None, mode: str = 'infer', *args, **kwargs)[source]¶ Abstract class for deep learning components.
-
class
deeppavlov.core.models.torch_model.
TorchModel
(model: torch.nn.Module, device: Union[torch.device, str] = 'cuda', optimizer: str = 'AdamW', optimizer_parameters: Optional[dict] = None, learning_rate_drop_patience: Optional[int] = None, learning_rate_drop_div: Optional[float] = None, load_before_drop: bool = True, min_learning_rate: float = 1e-07, clip_norm: Optional[float] = None, *args, **kwargs)[source]¶ Class implements torch model’s main methods.
- Parameters
model – torch.nn.Model-based neural network model
device – device to use
optimizer – name of torch.optim optimizer
optimizer_parameters – dictionary with optimizer parameters
learning_rate_drop_patience – how many validations with no improvements to wait
learning_rate_drop_div – the divider of the learning rate after learning_rate_drop_patience unsuccessful validations
load_before_drop – whether to load best model before dropping learning rate or not
min_learning_rate – min value of learning rate if learning rate decay is used
args –
kwargs – dictionary with other model parameters
-
device
¶ cpu or cuda device to use
-
opt
¶ dictionary with all model parameters
-
model
¶ torch model
-
epochs_done
¶ number of epochs that were done
-
optimizer
¶ torch.optim instance
-
learning_rate_drop_patience
¶ how many validations with no improvements to wait
-
learning_rate_drop_div
¶ the divider of the learning rate after learning_rate_drop_patience unsuccessful validations
-
load_before_drop
¶ whether to load best model before dropping learning rate or not
-
min_learning_rate
¶ min value of learning rate if learning rate decay is used
-
clip_norm
¶ clip gradients by norm coefficient