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: Union[str, pathlib.Path, None], load_path: Union[str, pathlib.Path, None] = None, mode: str = 'infer', *args, **kwargs)[source]

deeppavlov.models.model.serializable.Serializable is an 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: Union[str, pathlib.Path, None], load_path: Union[str, pathlib.Path, None] = 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: Union[str, pathlib.Path, None], load_path: Union[str, pathlib.Path, None] = None, mode: str = 'infer', *args, **kwargs)[source]

Abstract class for deep learning components.

class deeppavlov.core.models.tf_backend.TfModelMeta[source]

Metaclass that helps all child classes to have their own graph and session.

class deeppavlov.core.models.tf_model.TFModel(*args, **kwargs)[source]

Parent class for all components using TensorFlow.

class deeppavlov.core.models.keras_model.KerasModel(**kwargs)[source]

Builds Keras model with TensorFlow backend.

epochs_done

number of epochs that were done

batches_seen

number of epochs that were seen

train_examples_seen

number of training samples that were seen

sess

tf session

class deeppavlov.core.models.keras_model.KerasWrapper(cls: type, save_path: Optional[str] = None, load_path: Optional[str] = None, mode: str = None, **kwargs)[source]

A wrapper over external Keras models. It is used, for example, to wrap CharacterTagger. A subclass of KerasModel

cls

the class to be wrapped

save_path

the path where model is saved

load_path

the path from where model is loaded

mode

usage mode

**kwargs

a dictionary containing model parameters specified in the main part of json config that corresponds to the model

class deeppavlov.core.models.lr_scheduled_model.LRScheduledModel(learning_rate: Union[None, float, Tuple[float, float]] = None, learning_rate_decay: Union[str, deeppavlov.core.models.lr_scheduled_model.DecayType, Tuple[Union[str, deeppavlov.core.models.lr_scheduled_model.DecayType], float]] = <DecayType.NO: 1>, learning_rate_decay_epochs: int = 0, learning_rate_decay_batches: int = 0, learning_rate_drop_div: float = 2.0, learning_rate_drop_patience: Optional[int] = None, momentum: Union[None, float, Tuple[float, float]] = None, momentum_decay: Union[str, deeppavlov.core.models.lr_scheduled_model.DecayType, Tuple[Union[str, deeppavlov.core.models.lr_scheduled_model.DecayType], float]] = <DecayType.NO: 1>, momentum_decay_epochs: int = 0, momentum_decay_batches: int = 0, fit_batch_size: Union[None, int, str] = None, fit_learning_rate: Tuple[float, float] = (1e-07, 100), fit_learning_rate_div: float = 10.0, fit_beta: float = 0.98, fit_min_batches: int = 10, fit_max_batches: Optional[int] = None, *args, **kwargs)[source]

Abstract model enhanced with optimizer, learning rate and momentum management and search.

Parameters:
  • learning_rate – learning rate value or ranges
  • learning_rate_decay

    learning rate decay type Set of values: “linear”, “onecycle”, “trapezoid”,

    ”exponential”, “cosine”, [“polynomial”, K], where K is a polynomial power
  • learning_rate_decay_epochs – number of epochs for learning rate decay process
  • learning_rate_decay_batches – number of batches for learning rate decay process
  • learning_rate_drop_div – division coefficient for learning rate in case of exceeding patience learning_rate_drop_patience
  • learning_rate_drop_patience – patience limit of loss increase
  • momentum – range of momentum values
  • momentum_decay

    momentum decay type. Set of values: “linear”, “onecycle”, “trapezoid”,

    ”exponential”, “cosine”, [“polynomial”, K], where K is a polynomial power
  • momentum_decay_epochs – number of epochs for momentum decay process
  • momentum_decay_batches – number of batches for momentum decay process
  • fit_batch_size – batch size when fitting learning rate
  • fit_learning_rate – range of learning rate values to explore
  • fit_learning_rate_div – division coefficient for best learning rate obtained from fitting, divided learning rate value will be used when training model
  • fit_beta – smoothing coefficient for loss calculation when fitting learning rate
  • fit_min_batches – number of batches to train model on before fitting learning rate
  • fit_max_batches – number of batches to train model on when fitting learning rate
  • *args – other parameters
  • **kwargs – other parameters