braindecode.modules.FeedForwardBlock#
- class braindecode.modules.FeedForwardBlock(emb_size, expansion, drop_p, activation=<class 'torch.nn.modules.activation.GELU'>, *, hidden_features=None, gated=False, bias=True, output_drop_p=0.0)[source]#
Feedforward network block.
- Parameters:
emb_size (int) – Embedding dimension.
expansion (int) – Expansion factor for the hidden layer size.
drop_p (float) – Dropout probability.
activation (
type[Module]) – Activation function constructor.hidden_features (
int|None) – Hidden width, overridingexpansion * emb_sizewhen supplied.gated (
bool) – Use a separate activated gate projection multiplied by the value projection, rather than activating the value projection directly. Gated blocks register named projections (fc1,fc_gate,fc2); ungated blocks retain their sequential numeric child names.bias (
bool) – Include a bias in each linear projection.output_drop_p (
float) – Dropout probability after the output projection. The ungated default does not add an output dropout module.
Examples
>>> import torch >>> from braindecode.modules import FeedForwardBlock >>> module = FeedForwardBlock(emb_size=32, expansion=2, drop_p=0.1) >>> inputs = torch.randn(2, 10, 32) >>> outputs = module(inputs) >>> outputs.shape torch.Size([2, 10, 32])
Methods