braindecode.modules.FourierEmb#

class braindecode.modules.FourierEmb(dimension=2048, margin=0.2)[source]#

2D Fourier positional embedding over electrode (x, y) in [0, 1].

Matches neuraltrain.models.common.FourierEmbModel (parity-gated) so ChannelMerger produces identical attention scores.

Parameters:
  • dimension (int) – Output embedding dimension. dimension == (n_freqs ** 2) * 2 with n_freqs = round((dimension / 2) ** 0.5) (must be an integer; 32 for the default 2048).

  • margin (float) – Position offset/width term from the upstream construction.

Methods

forward(positions)[source]#

Define 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.

Return type:

Tensor