Activation Functions: Making Neural Networks Nonlinear
An activation function acts as a gatekeeper for a neuron, deciding what signal to pass on. It introduces non-linearity, allowing networks to learn complex patterns. A network with only linear activations collapses into a simple, less powerful model.
WHY IT EXISTS Real-world data is messy and complex; relationships between inputs and outputs are rarely simple straight lines. A neural network built only from linear operations, no matter how many layers deep, can only ever learn linear relationships. Activation functions were created to introduce non-linearity, giving networks the power to model complex, non-trivial problems.
THE MENTAL MODEL Think of an activation function as a dimmer switch or a gatekeeper for a single neuron. After a neuron adds up all the signals it receives, it doesn't just pass the total along. Instead, it runs that total through its activation function to decide whether the signal is strong enough to matter, and if so, how much of that signal to pass on to the next layer of neurons.
HOW IT WORKS Inside a neuron, all incoming signals are multiplied by their respective weights and then summed together. This weighted sum is then fed into an activation function. For example, the popular ReLU (Rectified Linear Unit) function is very simple: if the input sum is positive, it passes the value through unchanged; if the sum is negative, it outputs zero. This output then becomes an input for neurons in the next layer. This simple, non-linear step, repeated across millions of neurons, enables the network to learn.
WHEN TO USE IT Activation functions are used in the hidden layers of virtually all neural networks. They are the key ingredient that allows deep learning models to learn hierarchical features from complex datasets like images, audio, and natural language. Different functions are suited for different tasks, but the principle of adding non-linearity is universal.
WHEN NOT TO USE IT If you use only linear activation functions throughout a multi-layer network, you've accidentally built a simple linear model. The layers all collapse into a single linear operation, completely wasting the network's depth. The main place a linear (or no) activation is appropriate is the final output layer of a regression model, where you need to predict a continuous value that isn't bounded.
ONE CANONICAL EXAMPLE A simple network with a linear activation cannot solve the classic XOR problem, because the data isn't linearly separable. You can't draw a single straight line to divide the true and false outputs. However, by adding just one hidden layer with a non-linear activation function (like ReLU or Sigmoid), the network can bend the decision space and easily solve the problem. This demonstrates the power of non-linearity.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.