braindecode.modules.LearnedPositionalEncoding#

class braindecode.modules.LearnedPositionalEncoding(length, dim, drop_prob=0.0)[source]#

Learned additive positional encoding, dropout(x + encoding[:, :seq]).

The encoding parameter is drawn from N(0, 1), shape (1, length, dim); a shorter sequence uses its first rows. CTNet and MSCFormer use it, so their released weights load with the same keys.

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

  • dim (int) – Token width.

  • drop_prob (float) – Dropout after the addition.

Methods

forward(x)[source]#

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

Return type:

Tensor