espnet2.lm.abs_model.AbsLM
espnet2.lm.abs_model.AbsLM
class espnet2.lm.abs_model.AbsLM(*args, **kwargs)
Bases: Module
, BatchScorerInterface
, ABC
The abstract LM class
To share the loss calculation way among different models, We uses delegate pattern here: The instance of this class should be passed to “LanguageModel”
>>> from espnet2.lm.abs_model import AbsLM
>>> lm = AbsLM()
>>> model = LanguageESPnetModel(lm=lm)
This “model” is one of mediator objects for “Task” class.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
abstract forward(input: Tensor, hidden: Tensor) → Tuple[Tensor, Tensor]
Defines the computation performed at every call.
Should be overridden by all subclasses.
NOTE
Although the recipe for forward pass needs to be defined within this function, one should call the Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.