spd_learn.modules.LearnedSinusoidalPosition#
- class spd_learn.modules.LearnedSinusoidalPosition(sequence_length=30, embed_dim=6, *, device=None, dtype=None)[source]#
Bases:
ModuleAdd learned sinusoidal positional features to log tokens.
- Parameters:
sequence_length (int, default=30) – Number of ordered input tokens.
embed_dim (int, default=6) – Triangular log-coordinate dimension.
device (torch.device or str, optional) – Device for parameters and buffers.
dtype (torch.dtype, optional) – Data type for parameters and buffers.
- forward(x: Tensor) Tensor[source]#
Encode an ordered log-token sequence.
- Parameters:
x (torch.Tensor) – Log tokens of shape (batch, tokens, embed_dim).
- Returns:
Encoded tokens with the input shape.
- Return type: