How a Neuron Calculates Output
A neuron receives input values, combines them with weights, adds a bias, and then usually passes the result through an activation function to produce its output.
In simple words
A neuron takes numbers, gives each input a learned influence using weights, adds a bias, and then transforms the result into an output.
The Complete Calculation
Every step has a specific purpose. Let's calculate a complete example.
Step 1 — Start With the Inputs
Suppose our neuron receives two input values.
x₁ = 2
x₂ = 3
Think of these simply as two pieces of information entering the neuron.
Step 2 — Give Each Input a Weight
Each input has a corresponding weight.
w₁ = 0.5
w₂ = 0.4
Now multiply each input by its weight.
x₁ × w₁
2 × 0.5 = 1.0
x₂ × w₂
3 × 0.4 = 1.2
We now have two weighted values:
Step 3 — Add the Weighted Values
Now add the results together.
1.0 + 1.2 = 2.2
Our weighted sum is therefore:
Step 4 — Add the Bias
Now suppose the neuron has a bias of:
b = 1
Add the bias to the weighted sum.
2.2 + 1 = 3.2
So the value before the activation function is:
The Formula
Instead of writing every calculation separately, we can represent the calculation with one formula:
z = (x₁ × w₁) + (x₂ × w₂) + b
Using our values:
z = (2 × 0.5) + (3 × 0.4) + 1
z = 1.0 + 1.2 + 1
z = 3.2
Remember
x means input, w means weight, b means bias, and z is the weighted sum plus bias.
Step 5 — Apply an Activation Function
The value we calculated, 3.2, is normally passed through an activation function.
The activation function determines how the neuron's value is transformed.
We will study activation functions in detail in Lesson 3 — Activation Functions.
Complete Example From Start to Finish
Let's put everything together.
Inputs:
x₁ = 2
x₂ = 3
Weights:
w₁ = 0.5
w₂ = 0.4
Bias:
b = 1
First calculate the weighted inputs:
2 × 0.5 = 1.0
3 × 0.4 = 1.2
Add them:
1.0 + 1.2 = 2.2
Add the bias:
2.2 + 1 = 3.2
Finally, pass the result through the activation function.
Example With Three Inputs
Real neural network neurons can receive many inputs. Suppose we have three:
x₁ = 2
x₂ = 4
x₃ = 5
Their weights are:
w₁ = 0.3
w₂ = 0.5
w₃ = 0.2
And the bias is:
b = 1
Calculate each weighted input:
2 × 0.3 = 0.6
4 × 0.5 = 2.0
5 × 0.2 = 1.0
Add them:
0.6 + 2.0 + 1.0 = 3.6
Add the bias:
3.6 + 1 = 4.6
Calculate a Neuron With Python
We can perform the same calculation using simple Python.
x1 = 2
x2 = 3
w1 = 0.5
w2 = 0.4
bias = 1
z = (x1 * w1) + (x2 * w2) + bias
print(z)
Output:
3.2
The Python code is doing exactly the same calculation we performed manually.
Turn It Into a Function
We can make the calculation reusable by putting it inside a function.
def neuron_output(x1, x2, w1, w2, bias):
return (x1 * w1) + (x2 * w2) + bias
result = neuron_output(2, 3, 0.5, 0.4, 1)
print(result)
Output:
3.2
This function represents the basic mathematical calculation performed by a very simple neuron.
What Is the Neuron Actually Learning?
The neuron is not normally learning the input values. The input data is provided to it.
During training, the model learns better values for its parameters, especially the weights and bias.
Why Do Different Weights Matter?
Consider two inputs with different weights.
Input 1 = 10
Weight 1 = 0.1
Input 2 = 10
Weight 2 = 0.9
Their contributions are very different:
10 × 0.1 = 1
10 × 0.9 = 9
Even though both inputs are 10, their contributions to the neuron are different because their weights are different.
Key idea
The weight controls how strongly an input contributes to the neuron's calculation.
What If a Weight Is Negative?
A weight can also be negative.
Input = 5
Weight = -0.5
5 × -0.5 = -2.5
A negative weight contributes negatively to the weighted sum.
This is why it is more accurate to say that a weight controls the direction and strength of an input's influence, rather than simply saying that it represents importance.
The Complete Neuron
Inputs
↓
Multiply each input by its weight
↓
Add weighted values
↓
Add bias
↓
Apply activation function
↓
Neuron output
From One Neuron to a Neural Network
One neuron is only a small part of a neural network. Many neurons are connected together in layers.
Each neuron performs its own calculation, and the outputs are passed through the network until the final prediction is produced.
The Big Picture
This is the basic operation that happens repeatedly inside a neural network.
What You Should Remember
A neuron multiplies each input by its weight, adds the weighted values together, adds a bias, and normally passes the result through an activation function.
Check Your Understanding
What happens first?
Each input is multiplied by its corresponding
weight.
What happens after that?
The weighted values are added together.
Where does the bias come in?
The bias is added to the weighted sum.
What happens next?
The result is normally passed through an
activation function.
What does training change?
Training adjusts the weights and bias so the
network can improve its predictions.