DEEP LEARNING LESSON 3 ACTIVATION FUNCTIONS

Step Function

The Step Function is a simple activation function that converts a value into either 0 or 1 based on a threshold.

In simple words

The Step Function asks a simple question: Is the input greater than the threshold? If yes, it returns 1. Otherwise, it returns 0.

How Does the Step Function Work?

The simplest Step Function uses zero as the threshold.

if z > 0:
    output = 1
else:
    output = 0

So there are only two possible outputs:

z > 0
Output = 1
z ≤ 0
Output = 0

Example 1 — Positive Input

Suppose the neuron calculates:

z = 3.2

The Step Function checks:

3.2 > 0

This is true, so the output is:

output = 1
z = 3.2
Step Function
1

Example 2 — Negative Input

Now suppose the neuron calculates:

z = -2.5

The Step Function checks:

-2.5 > 0

This is false, so the output is:

output = 0
z = -2.5
Step Function
0

What Happens When z Is Zero?

With the rule we are using:

if z > 0:
    output = 1
else:
    output = 0

When:

z = 0

The condition z > 0 is false. Therefore:

output = 0

Step Function Examples

Input z
Output
-5
0
-1
0
0
0
1
1
5
1

Think of It Like a Switch

The Step Function behaves like an on/off switch.

Negative
OFF
0
Positive
ON
1

This is why the Step Function is easy to understand: it makes a simple binary decision.

Real-World Example — Pass or Fail

Imagine a model that decides whether a student passes an exam.

Suppose the model produces a score:

score = 0.8

We could define:

if score > 0.5:
    pass = 1
else:
    pass = 0

Since:

0.8 > 0.5

the model produces:

pass = 1
Score = 0.8
Threshold = 0.5
Pass = 1

The Threshold Does Not Have to Be Zero

Zero is only the simplest example. We can choose a different threshold.

For example:

threshold = 0.5

if z > threshold:
    output = 1
else:
    output = 0

Now suppose:

z = 0.8

Compare the value with the threshold:

0.8 > 0.5

Therefore:

output = 1

Step Function With Python

We can write the Step Function as a Python function.

def step_function(z):

    if z > 0:
        return 1
    else:
        return 0


print(step_function(3.2))
print(step_function(-2.5))
print(step_function(0))

Output:

1
0
0

How the Python Code Works

This line creates the function:

def step_function(z):

The function expects one value called z.

Then Python checks:

if z > 0:

If that condition is true, Python executes:

return 1

Otherwise, it executes:

return 0

So:

step_function(4)

returns:

1

while:

step_function(-3)

returns:

0

How the Step Function Fits Into a Neuron

Remember the complete neuron calculation:

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

output = step_function(z)

For example:

x1 = 2
x2 = 3

w1 = 0.5
w2 = 0.4

bias = 1

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

output = step_function(z)

print(output)

First:

z = (2 × 0.5) + (3 × 0.4) + 1
z = 3.2

Then:

step_function(3.2)

Because `3.2 > 0`, the final output is:

1
Inputs
Weights + Bias
z = 3.2
Step Function
Output = 1

The Main Problem With the Step Function

The Step Function gives only two outputs:

0
or
1

There is no gradual change between these values.

For example, these inputs:

0.01
0.5
0.9
10

would all produce:

1

as long as they are greater than zero.

This makes the Step Function useful for learning the basic idea, but it is not generally suitable for training modern neural networks because its hard threshold does not provide a useful gradient for gradient-based learning.

Step Function vs Sigmoid

Step Function
Sigmoid
Outputs 0 or 1
Outputs values between 0 and 1
Sharp threshold
Smooth transition
Simple to understand
More useful for gradient-based learning

We will study Sigmoid in detail later in this lesson.

The Big Picture

Inputs
   ↓
Weights
   ↓
Weighted Sum
   ↓
+ Bias
   ↓
z
   ↓
Step Function
   ↓
0 or 1

The Step Function turns the neuron's calculated value into a simple binary output.

What You Should Remember

The Step Function compares the neuron's input with a threshold. If the value is above the threshold, it returns 1. Otherwise, it returns 0. It is useful for understanding activation functions, but its hard 0/1 behavior makes it unsuitable for most modern neural-network training.

QUICK CHECK

Check Your Understanding

What does the Step Function return?
In our basic version, it returns either 0 or 1.

What happens when z = 5?
The output is 1 because 5 is greater than 0.

What happens when z = -2?
The output is 0 because -2 is not greater than 0.

Why isn't Step Function commonly used for training modern neural networks?
Its hard threshold does not provide a useful gradient for gradient-based optimization.

NEXT TOPIC

Sigmoid

The Step Function makes a hard 0-or-1 decision. Next, we will learn Sigmoid, which produces a smooth value between 0 and 1.