Channel Mixing with GELU
Channel Mixing in MLP-Mixer applies an MLP independently to each token's features:
Or equivalently per-token:
Where:
- : Input tokens
- : Expand to hidden dim H
- : Project back to D
- GELU: Gaussian Error Linear Unit activation
GELU approximation:
Task: Implement channel mixing with GELU activation.
Example
X (2×2), W1 = I (2×4), W2 = I (4×2)
GELU applied element-wise to X
With identity-like projections, the MLP reduces to applying GELU to each element. GELU(1) ≈ 0.8412, GELU(0) = 0.
Constraints
- : Number of tokens
- : Input/output dimension
- : Hidden dimension (typically 4×D)