PositionalEncoding

class PositionalEncoding(d_model: int, dropout: float = 0.1, max_len: int = 5000)[source]

Bases: torch.nn.modules.module.Module

Positional encoding of tokens and reshaping.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

Methods

forward(x)

x: Tensor, shape [batch_size, input_size, patch_num, embedding_dim].

Attributes

Parameters
  • d_model (int) –

  • dropout (float) –

  • max_len (int) –

forward(x: torch.Tensor) torch.Tensor[source]

x: Tensor, shape [batch_size, input_size, patch_num, embedding_dim].

Parameters

x (torch.Tensor) –

Return type

torch.Tensor