Activation Function.

Mathematical functions like ReLU, GELU, or SwiGLU that introduce nonlinearity into neural networks, enabling them to learn complex patterns beyond linear relationships.

Activation functions are mathematical operations applied to the outputs of neural network layers that introduce nonlinearity into otherwise linear transformations. Without activation functions, even deep neural networks would collapse into simple linear models, unable to capture the complex patterns needed for tasks like language understanding, image recognition, or reasoning. They serve as the crucial component that allows networks to approximate any continuous function and learn sophisticated representations from data.

The most common activation functions include ReLU (Rectified Linear Unit), which outputs the input if positive and zero otherwise; GELU (Gaussian Error Linear Unit), which provides smoother gradients through a probabilistic approach; and SwiGLU, which combines swish activation with gating mechanisms for improved performance in transformer architectures. Each function has different mathematical properties affecting gradient flow, computational efficiency, and model expressiveness. Modern architectures often use different activation functions in different parts of the network, with SwiGLU becoming popular in large language models for its superior performance despite higher computational cost.

The choice of activation function significantly impacts training dynamics, model capacity, and computational requirements. ReLU remains popular for its simplicity and computational efficiency, but can suffer from dead neurons where units permanently output zero. GELU and SwiGLU provide smoother gradients that can improve training stability and final performance, particularly in large models, though at the cost of increased computation. A common misconception is that newer activation functions are always better—the optimal choice depends on the specific architecture, dataset, and computational constraints of the application.