N Neurarch Architectures Checks Docs Open the app

Architectures / Biosignal

🧠 EEG Conformer

Conv stem + Transformer encoder — SOTA for high-channel motor imagery EEG (Song 2023)

Layers
23
Parameters
78.6K
Input
1 × 22 × 1000
Output
4
Verifier
1 advisory

Every number on this page is computed from the graph by the same functions the app runs, not written by hand.

Open EEG Conformer on the canvas Free, no account needed

When to pick it

Pick when you have ≥16 channels and ~400+ trials per subject. Best published accuracy on BCI IV-2a/2b; expect tricky regularization.

Structure

23 layers. Output shapes are propagated from the input shape, batch dimension excluded.

LayerTypeParametersOutput shape
1eeg_windowInputshape=[1, 22, 1000]1 × 22 × 1000
2temporal_convConv2DoutChannels=40, kernelSize=[1, 25], stride=140 × 22 × 976
3spatial_convConv2DoutChannels=40, kernelSize=[22, 1], stride=140 × 1 × 976
4normBatchNormnormalizedShape=4040 × 1 × 976
5actELU40 × 1 × 976
6poolAvgPool2DkernelSize=[1, 75], stride=[1, 15]40 × 1 × 61
7patch_projConv2DoutChannels=40, kernelSize=[1, 1], stride=140 × 1 × 61
8to_tokensPermute61 × 1 × 40
9normLayerNormnormalizedShape=4061 × 1 × 40
10self_attnMulti-Head AttentionembedDim=40, numHeads=1061 × 1 × 40
11residualAdd61 × 1 × 40
12normLayerNormnormalizedShape=4061 × 1 × 40
13denseFeed ForwardembedDim=40, ffDim=16061 × 1 × 40
14residualAdd61 × 1 × 40
15normLayerNormnormalizedShape=4061 × 1 × 40
16self_attnMulti-Head AttentionembedDim=40, numHeads=1061 × 1 × 40
17residualAdd61 × 1 × 40
18normLayerNormnormalizedShape=4061 × 1 × 40
19denseFeed ForwardembedDim=40, ffDim=16061 × 1 × 40
20residualAdd61 × 1 × 40
21flattenFlatten2440
22classifierLinearoutFeatures=44
23logitsOutput4

What the verifier says

The same 41 structural checks that run on every edit in the app, on this graph.

warn2 attention layer(s) present but no positional encoding found. Attention is permutation-invariant, without position information the model cannot distinguish token order. Fix: Add a PositionalEncoding (sinusoidal) or RoPE layer before the first attention layer. (self_attn)
attention-no-pe

The PyTorch it exports

Generated from the graph above. First 46 lines; the app exports the whole file, plus the training loop, the data contract and a deploy bundle.

# Architecture designed with Neurarch: https://neurarch.com
# PyTorch: compatible with Python 3.8+ and torch>=1.12
# Colab: pip install torch torchvision  (usually pre-installed)
#
# WARNING: 1 layer(s) below are not yet supported by the PyTorch
# exporter and pass their input through UNCHANGED in forward():
#   - to_tokens (permute)

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class EEGConformer(nn.Module):
    def __init__(self):
        super().__init__()

        self.conv2d_1 = nn.Conv2d(1, 40, kernel_size=(1, 25), stride=1, padding=0)
        self.conv2d_2 = nn.Conv2d(40, 40, kernel_size=(22, 1), stride=1, padding=0)
        self.batchNorm_1 = nn.BatchNorm2d(40)
        self.elu_1 = nn.ELU(alpha=1)
        self.avgpool2d_1 = nn.AvgPool2d(kernel_size=(1, 75), stride=(1, 15), padding=0)
        self.conv2d_3 = nn.Conv2d(40, 40, kernel_size=(1, 1), stride=1, padding=0)
        self.layerNorm_1 = nn.LayerNorm(40)
        self.multiHeadAttention_1 = nn.MultiheadAttention(embed_dim=40, num_heads=10, batch_first=True)
        self.layerNorm_2 = nn.LayerNorm(40)
        self.feedForward_1 = nn.Sequential(
            nn.Linear(40, 160),
            nn.ReLU(),
            nn.Linear(160, 40)
        )
        self.layerNorm_3 = nn.LayerNorm(40)
        self.multiHeadAttention_2 = nn.MultiheadAttention(embed_dim=40, num_heads=10, batch_first=True)
        self.layerNorm_4 = nn.LayerNorm(40)
        self.feedForward_2 = nn.Sequential(
            nn.Linear(40, 160),
            nn.ReLU(),
            nn.Linear(160, 40)
        )
        self.linear_1 = nn.Linear(2440, 4)

    def forward(self, x):
        # eeg_window shape: [1,22,1000]
        conv2d_mporal = self.conv2d_1(x)
        conv2d_patial = self.conv2d_2(conv2d_mporal)
        batch_norm_bn_1 = self.batchNorm_1(conv2d_patial)

For agents

This architecture is machine-readable end to end. An agent can list the set, fetch this graph, edit it, and have the edit verified before any GPU time is spent.

Also in Biosignal

🧠 EEGNet
Compact CNN for EEG/BCI — depthwise + separable convs make it 10× lighter than standard CNNs
16 layers · 2.7K