embedding¶
-
class
hanlp.layers.embeddings.embedding.
Embedding
[source]¶ Base class for embedding builders.
-
class
hanlp.layers.embeddings.embedding.
ConcatModuleList
(*modules: Optional[Iterable[torch.nn.modules.module.Module]], dropout=None)[source]¶ A
nn.ModuleList
to bundle several embeddings modules.- Parameters
*modules – Embedding layers.
dropout – Dropout applied on the concatenated embedding.
-
forward
(batch: dict, **kwargs)[source]¶ 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.
-
class
hanlp.layers.embeddings.embedding.
EmbeddingList
(*embeddings_, embeddings: dict = None, dropout=None)[source]¶ An embedding builder to bundle several embedding builders.
- Parameters
*embeddings_ – A list of embedding builders.
embeddings – Deserialization for a dict of embedding builders.
dropout – Dropout applied on the concatenated embedding.