AI Neurons and Perceptrons
A perceptron is the basic building block behind neural networks: it multiplies each input by a weight, adds a bias, and passes the result through an activation function to produce an output.
A Loose Analogy, Not a Simulation
Artificial neurons take their name from biological ones, where a neuron receives signals from other neurons, combines them, and fires a signal onward once the combined input crosses a threshold. An artificial neuron borrows the shape of that idea but is a plain mathematical function — it does not simulate the chemistry or biology of a real brain cell.
Anatomy of a Perceptron
- Inputs (x1, x2, ... xn) — the numeric values the perceptron receives
- Weights (w1, w2, ... wn) — one per input, representing how much that input matters
- A bias (b) — a constant added to the weighted sum, independent of the inputs
- An activation function — turns the weighted sum into the perceptron's final output
Putting these together, a perceptron first computes a weighted sum: z = (w1 x x1) + (w2 x x2) + ... + (wn x xn) + b. That single number z is then passed through an activation function to produce the output. Larger weights mean that input has more influence on the outcome; a weight near zero means that input is nearly ignored.
Example
def perceptron(inputs, weights, bias):
z = sum(x * w for x, w in zip(inputs, weights)) + bias
# step activation: fire (1) if z is positive, otherwise stay at 0
return 1 if z > 0 else 0
inputs = [1, 0, 1]
weights = [0.6, -0.2, 0.9]
bias = -0.5
print(perceptron(inputs, weights, bias)) # 1
Without a bias, a perceptron's decision boundary would always have to pass through the origin, since z would be exactly zero whenever every input is zero. The bias shifts that boundary freely, letting the perceptron fire (or stay off) even when every input is zero, or requiring a stronger combined signal before it fires at all.
Activation Functions Add Nonlinearity
From One Perceptron to a Network
A single perceptron can only separate patterns that are linearly separable — cleanly divided by a straight line or flat plane. Stacking many perceptrons into layers, where one layer's output feeds the next, only helps because of the nonlinear activation function: without it, any number of stacked layers would mathematically collapse into a single linear function. With nonlinearity in place, a multi-layer network can represent far more complex, curved decision boundaries — exactly the layered structure that makes deep learning, introduced on the previous page, work.