braindecode.modules.ChannelMerger#
- class braindecode.modules.ChannelMerger(out_channels=270, pos_dim=2048, dropout=0.2, invalid_value=-0.1)[source]#
Spatial Fourier-attention merge:
n_chans->out_channels.Montage-agnostic spatial attention: each virtual channel softmax-attends over the input channels using a learned head weighted against a Fourier embedding of the electrode
(x, y)positions. Matchesneuraltrain.models.common.ChannelMergerModel(parity-gated); braindecode has no subjects, soper_subject=Falseandsubject_idsis dropped.- Parameters:
out_channels (
int) – Number of virtual output channels. The default is270.pos_dim (
int) – Fourier embedding dimension. The default is2048.dropout (
float) – Spatial-attention dropout radius (non-parametric, training only) – NOT a Bernoulli probability. Each training step draws a random center in normalized[0, 1]^2position space and bans every channel within this radius from the softmax. Values>= 1ban all channels and zero the output. The default is0.2.invalid_value (
float) – Position value marking padded/invalid channels (masked out of the softmax). The default is-0.1.
Methods
- forward(x, 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type: