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.
has a sharp corner at zero and is completely flat below it, so negative inputs get no gradient. , where is the probability that a standard normal random number is less than . The result is a smooth curve that lets small negative values through. Gradients behave better, at a little more compute.
Swish, , 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
GELU lets a small negative value through; large positive inputs pass almost unchanged.
Where the course uses it
Related terms
- FFN — the feed-forward networkRead "F F N of x". It is a small two-layer neural network applied to each token's vector on its own, with the same weights for every token.
- ⊙ — element-wise productRead "a times b, element-wise". Multiply two same-shaped vectors or matrices position by position. This is not matrix multiplication.