Activations and Gates Change the MLP

ReLU, GELU, and gated MLPs preserve the same outer interface while calculating different functions. Compare numerical outputs, derive a gated branch, and account for its additional projection.

The operation between the MLP projections is part of the architecture. ReLU, GELU, and gated variants can have the same input and output shapes while calculating different functions.

ReLU and GELU Treat Negative Inputs Differently

ReLU uses max(0,x)\max(0,x). GELU weights an input by the standard normal cumulative distribution:

GELU(x)=xΦ(x).\operatorname{GELU}(x)=x\Phi(x).

For x=1,0,1x=-1,0,1, exact GELU is approximately

[0.158655,0,0.841345],[-0.158655,0,0.841345],

whereas ReLU returns [0,0,1][0,0,1]. GELU can retain a small negative value and smoothly changes near zero. An implementation should also state whether it uses exact GELU or an approximation.

A Gate Uses Two Expanded Projections

A gated MLP can be written as

h=ϕ(rWg)(rWv),m=hWdown,h=\phi(rW_g)\odot(rW_v),\qquad m=hW_{down},

where \odot is coordinate-wise multiplication. One projection decides how strongly each expanded coordinate opens; the other supplies the value being gated.

If the gate preactivation is [1,1][1,-1], the value branch is [2,3][2,3], and ϕ\phi is ReLU, then

ReLU([1,1])[2,3]=[2,0].\operatorname{ReLU}([1,-1])\odot[2,3]=[2,0].

SwiGLU uses the SiLU activation in the gate and is one member of this broader family. Names alone are not enough: record the activation and every projection shape.

Compare Under a Parameter Budget

A gated MLP has an additional input projection. Keeping the same dffd_{ff} therefore increases parameters and computation relative to a two-projection MLP. Fair comparisons often reduce the gated hidden width, but the exact ratio depends on biases and conventions. State the actual shapes instead of relying on “same size.”

Q1. Calculate a gated coordinate

A ReLU gate receives 2-2 and its value branch receives 55. What value reaches the down projection at that coordinate?

Compute it first, then check your number.

Hint
Apply ReLU before multiplying by the value.
Solution
max(0,2)×5=0\max(0,-2)\times5=0.
Not attempted
Review

Not marked done.

References

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.