DEEP LEARNING LESSON 3 ACTIVATION FUNCTIONS

Why Do We Need Activation Functions?

Activation functions allow neural networks to learn complex, non-linear patterns. Without them, adding more neural network layers would not provide the expressive power we expect from deep learning.

In simple words

Activation functions give a neural network the ability to learn more complicated relationships than a simple straight-line calculation.

First, Remember What a Neuron Does

From the previous lessons, a neuron first calculates a weighted sum and adds a bias.

z = (x1 * w1) + (x2 * w2) + bias

Then the activation function is applied:

output = activation(z)
Inputs
Weights + Bias
z
Activation
Output

What Happens Without an Activation Function?

Suppose a neuron simply calculates:

output = z

That means the neuron is only performing a linear mathematical transformation.

Now imagine we connect several such layers together.

Input
Linear Layer
Linear Layer
Linear Layer
Output

It looks like a deep network, but mathematically the combination of linear transformations is still just another linear transformation.

A Simple Mathematical Example

Imagine the first layer performs:

y = 2x

Then the second layer performs:

z = 3y

Substitute `y`:

z = 3(2x)

z = 6x

We used two layers, but the final result is still just a linear function:

z = 6x

The important idea

Multiple linear layers without non-linear activation functions can be combined into a single linear transformation.

Adding More Layers Does Not Solve the Problem

You might think:

"If one layer is not powerful enough, why not just add 10 or 100 layers?"

The problem is that if every layer only performs a linear transformation, the entire network can still be represented as one linear transformation.

Linear
+
Linear
+
Linear
+
Linear
Still Linear

So simply making the network deeper does not magically make it capable of learning arbitrary complex patterns.

This Is Where Non-Linearity Comes In

Activation functions introduce a non-linear transformation between layers.

Linear Calculation
Non-Linear Activation
Next Layer

This allows different layers to learn different levels of complex relationships.

Example 1 — Recognizing a Cat

Imagine a neural network that receives an image.

Pixels
Edges
Shapes
Patterns
Cat

The network needs to learn complicated relationships between thousands or millions of values.

A simple linear calculation is not enough to represent all of these relationships. Non-linear activation functions allow the network to build more complex representations layer by layer.

Example 2 — Predicting House Prices

Suppose we want to predict a house price using:

Area
Bedrooms
Location
Age

Real house prices are influenced by combinations of these factors. For example, the effect of an additional bedroom may depend on the size and location of the house.

Features
Neural Network
Price Prediction

Activation functions help the network model these more complicated relationships.

Why Are They Especially Important in Deep Learning?

A deep neural network contains multiple layers.

INPUT
Data
LAYER 1
Linear
Activation
LAYER 2
Linear
Activation
OUTPUT
Prediction

The activation functions between layers allow the network to build increasingly complex representations.

Without vs With Activation Functions

Without Activation
With Activation
Mostly linear transformations
Can model non-linear relationships
More layers do not remove the linear limitation
Layers can build more complex representations
Limited expressive power
Much more expressive

See the Difference With Python

First, imagine a simple linear function:

def linear(x):
    return 2 * x


print(linear(3))

Output:

6

Now imagine applying another linear function:

def layer1(x):
    return 2 * x


def layer2(x):
    return 3 * x


value = layer1(3)
output = layer2(value)

print(output)

Output:

18

Mathematically:

3 × 2 × 3 = 18

The multiple layers still behave like one linear transformation:

output = 6 × x

Adding a Non-Linear Activation

Now introduce a simple ReLU activation:

def relu(x):
    return max(0, x)

The network can now perform:

value = layer1(3)

value = relu(value)

output = layer2(value)

print(output)

The activation function changes the behavior between layers.

Linear Layer
ReLU
Linear Layer
Output

This is the basic idea behind why activation functions make neural networks much more powerful.

Important

Activation functions do not magically make a model "smart." They provide the non-linear transformations that give a neural network the mathematical ability to represent complex patterns. The model still needs suitable data, architecture, loss functions, and training.

The Big Picture

Input
  ↓
Weights + Bias
  ↓
Linear Calculation
  ↓
Activation Function
  ↓
Non-Linear Output
  ↓
Next Layer
  ↓
Activation Function
  ↓
Next Layer
  ↓
Prediction

This pattern is repeated throughout a neural network.

What You Should Remember

Without activation functions, stacking linear layers still gives you a linear transformation. Activation functions introduce non-linearity, allowing deep neural networks to learn complex patterns.

QUICK CHECK

Check Your Understanding

Why do we need activation functions?
To introduce non-linearity so neural networks can learn complex relationships.

What happens if every layer is only linear?
The complete network can still be represented as a linear transformation.

Does adding more linear layers solve the problem?
No. Linear transformations composed together remain linear.

What does an activation function add?
A non-linear transformation between neural network layers.

NEXT TOPIC

Step Function

Now that you understand why activation functions are needed, we will start with one of the simplest activation functions: the Step Function.