braindecode.modules.TimmMlp#

class braindecode.modules.TimmMlp(in_features, hidden_features=None, out_features=None, act_layer=<class 'torch.nn.modules.activation.GELU'>, drop=0.0)[source]#

Two-layer MLP with timm’s parameter names (fc1, act, fc2, drop), as in ViT/MAE checkpoints: dropout after the activation and after the second layer. EEGPT and LUNA use it, so their released weights load with the same keys.

Parameters:
  • in_features (int)

  • hidden_features (int, optional) – Defaults to in_features.

  • out_features (int, optional) – Defaults to in_features.

  • act_layer (type of torch.nn.Module) – Activation class. Default: nn.GELU.

  • drop (float) – Dropout rate. Default: 0.0.

Methods

forward(x)[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.