Neural Networks Β· Neural Networks Β· 4 min read
What one neuron computes
A neural network looks complicated, but it is built from one small unit repeated thousands of times. That unit is the neuron, and it does something simple enough to write on one line. Learn this single operation and the rest of the course is just arrangement and repetition.
A neuron multiplies each input by a weight, adds the results together, and adds a bias. That one number is everything a neuron does.
The inputs, the weights, and the bias
A neuron receives several numbers as input. Each input is multiplied by its own weight, a number that says how much that input matters. The neuron adds up all those products and then adds one more number, the bias. The result is a single number:
Reading the symbols one by one:
- is the -th input, and is how many inputs there are.
- is the weight on input . A large weight makes that input count for more.
- is the bias, a fixed number added regardless of the inputs.
- is the dot product, a compact way to write .
- is the neuronβs output so far, a single number.
A worked example
Suppose a neuron has two inputs, , with weights and bias . Then:
The same calculation in code:
# the inputs to the neuron
x = [2.0, 3.0]
# one weight per input
w = [0.5, -1.0]
# a single bias term
b = 1.0
# multiply each input by its weight, sum them, then add the bias
z = sum(w_i * x_i for w_i, x_i in zip(w, x)) + b
print(z) # -1.0
That is the entire computation of one neuron. Notice the output can be any number, large, small, positive, or negative, because nothing yet limits its range.
In the next lesson, we will pass through an activation function so that neurons stacked together can do more than draw a single straight line.