What is an Activation Function?

An activation function helps a neural network decide how strongly a neuron should respond to information.

You can think of it like a decision switch: should the neuron activate a little, a lot, or not at all?

Without activation functions, neural networks could only learn simple straight-line relationships and would not be able to recognize complex patterns like images, handwriting, or speech.

Without Activation Function

A neural network without activation functions can only learn straight-line relationships.

y=2x+1

The model can only create simple straight-line patterns.

With Activation Function

Activation functions allow the neural network to learn more complex curved patterns.

f(x)=11+e−x

This flexibility helps neural networks recognize images, speech, and other real-world patterns.

Why Activation Functions Matter

Imagine predicting a student's exam score based on hours studied.

Real-world patterns are usually not perfectly straight lines.

Linear Model

A simple model assumes every extra hour helps equally.

y=5x
Hours StudiedExam Score

Realistic Pattern

Improvement may slow down after many hours of studying.

f(x)
Hours StudiedExam Score

Activation functions help neural networks learn realistic, non-linear patterns instead of only straight lines.

Step Function

The Step Function is one of the simplest activation functions.

It behaves like an ON/OFF switch:

  • Negative input → output becomes -1
  • Zero input → output becomes 0
  • Positive input → output becomes 1
f(x)={−1if x<00if x=01if x>0

Sigmoid Function

The Sigmoid function smoothly transforms values between 0 and 1.

  • Very negative numbers become close to 0
  • Very positive numbers become close to 1

This is useful when a neural network needs to estimate probability, such as:

  • Is this email spam?
  • Is this image a cat?
f(x)=11+e−x

TanH Function

The TanH function is similar to the Sigmoid function, but its outputs range from -1 to 1.

  • Negative inputs become negative outputs
  • Positive inputs become positive outputs

This helps the neural network represent information centered around 0.

f(x)=ex−e−xex+e−x

ReLU Function

ReLU stands for Rectified Linear Unit.

It is one of the most commonly used activation functions in modern neural networks.

  • Negative inputs become 0
  • Positive inputs stay unchanged

ReLU is simple, fast, and works very well for deep learning models.

f(x)=max(0,x)={xif x>00if x≤0