GELU⁡\operatorname{GELU}

GELU, ReLU, Swish — activation functions

The nonlinearity applied inside the feed-forward block. ReLU sets negative numbers to zero; GELU and Swish do almost the same but with a smooth curve.

ReLU⁡(z)=max⁡(0,z)\operatorname{ReLU}(z) = \max(0, z) has a sharp corner at zero and is completely flat below it, so negative inputs get no gradient. GELU⁡(z)=z⋅Φ(z)\operatorname{GELU}(z) = z \cdot \Phi(z), where Φ(z)\Phi(z) is the probability that a standard normal random number is less than zz. The result is a smooth curve that lets small negative values through. Gradients behave better, at a little more compute.

Swish, z⋅sigmoid⁡(z)z \cdot \operatorname{sigmoid}(z), has a very similar shape. SwiGLU uses two branches: one passes through Swish, the other stays linear, and the two are multiplied entry by entry, so one branch gates (scales up or down) the other.

Example

ReLU⁡(−1)=0,GELU⁡(−1)≈−0.16,GELU⁡(2)≈1.95\operatorname{ReLU}(-1) = 0, \quad \operatorname{GELU}(-1) \approx -0.16, \quad \operatorname{GELU}(2) \approx 1.95

GELU lets a small negative value through; large positive inputs pass almost unchanged.

Where the course uses it

Related terms