Every transformer block has two sub-layers: attention + this FFN. The FFN expands then contracts the representation.
FFN(x) = W2 ร GELU(W1 ร x + b1) + b2- W1: d_model โ d_ff (typically 4ร)
- W2: d_ff โ d_model
- GELU activation (smoother than ReLU)
With random weights, verify output shape matches input shape.
Round to **5 decimal places**.
Test Cases (2 visible ยท 1 hidden)
Case 1: GELU at 0
Input: gelu(0.0)
Expected: 0.0
Case 2: GELU at 1
Input: gelu(1.0)
Expected: 0.84134
โโต Run ยท โโงโต Submit