textbox.module.Embedder¶
Positional Embedding¶
- class textbox.module.Embedder.position_embedder.LearnedPositionalEmbedding(embedding_size, max_length=512)[source]¶
Bases:
Module
This module produces Learned Positional Embedding.
- forward(input_seq, offset=0)[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.
- training: bool¶
- class textbox.module.Embedder.position_embedder.SinusoidalPositionalEmbedding(embedding_size, max_length=512)[source]¶
Bases:
Module
This module produces sinusoidal positional embeddings of any length.
- forward(input_seq, offset=0)[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.
- static get_embedding(max_length, embedding_size)[source]¶
Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the description in Section 3.5 of “Attention Is All You Need”.
- training: bool¶