braindecode.modules.SinusoidalPositionalEncoding#

class braindecode.modules.SinusoidalPositionalEncoding(max_len, dim, drop_prob=0.0, persistent=False)[source]#

Fixed sinusoidal positional encoding, dropout(x + pe[:, :seq]).

The table pe of shape (1, max_len, dim) comes from braindecode.functional.sinusoidal_positional_encoding().

Parameters:
  • max_len (int) – Largest sequence length.

  • dim (int) – Token width.

  • drop_prob (float) – Dropout after the addition.

  • persistent (bool) – Store the table in the state_dict (released BIOT and MEDFormer checkpoints carry it).

Methods

forward(x)[source]#

(batch, seq, dim) -> (batch, seq, dim).

Return type:

Tensor