Skip to content

Activation Functions

Briefly

An activation function is a 'switch' for a neuron. It takes the weighted sum of inputs and decides how strongly the neuron should 'activate' for the next layer. Without it, the entire network would be equivalent to a single linear transformation and unable to learn complex patterns.

Activation Functions

Why They Are Needed

If neurons simply summed their inputs and passed the result forward, the entire neural network—no matter how many layers—would be equivalent to a single linear transformation. It would be unable to recognize faces, translate text, or write code. Activation functions add non-linearity, enabling the network to approximate almost any function.

Key Functions

Function Formula Where Used
ReLU max(0, x) Classic CNN, first Transformers
GELU x · Φ(x) BERT, modern Transformers
SiLU / Swish x · sigmoid(x) Llama, many LLM
Sigmoid 1 / (1 + e⁻ˣ) Output layers for probabilities
Tanh (eˣ − e⁻ˣ) / (eˣ + e⁻ˣ) RNN, LSTM
Softmax eˣᵢ / Σ eˣⱼ Output of language models

ReLU and Its Problem

ReLU is the simplest and cheapest function: all negative values become zero. This made it popular in computer vision. However, ReLU has the 'dead neuron' problem: if a neuron constantly outputs zero, it stops participating in learning.

Why LLMs Love GELU and SiLU

In language models (BERT, GPT, Llama), GELU and SiLU are used more frequently. They do not abruptly zero out negative values but gradually 'dampen' them. This helps the network retain more information and train more stably on massive volumes of text.

Softmax at the Output

When models need to predict the next word, the final layer converts raw numbers into a probability distribution through Softmax. The output is a list of probabilities for each token in the dictionary, and the model selects the most probable one.

See Also