What does a single artificial neuron (perceptron) actually compute?
A neuron takes a weighted sum of its inputs, adds a bias, and passes the result through an activation function. The weights encode learned feature importance, the bias shifts the decision boundary, and the activation introduces the non-linearity needed for complex mappings.
How to think about it
A neuron computes a two-step operation:
- Linear combination —
z = w · x + bwherewis the weight vector,xis the input vector, andbis the scalar bias. - Activation —
a = f(z)wherefis a non-linear function such as ReLU or sigmoid.
Stacking neurons into layers lets the network compose these operations: each layer re-represents the input in a new space, and the activation function is what prevents successive linear layers from collapsing.
import torch
import torch.nn as nn
# A single neuron: 4 inputs → 1 output
neuron = nn.Linear(4, 1) # computes z = Wx + b
output = torch.sigmoid(neuron(x)) # applies activation f(z)
The bias term is critical — without it the decision hyperplane is forced through the origin and the neuron cannot fit many real patterns.
The weight w_i roughly measures “how much does input feature i matter?” Positive weights amplify; negative weights suppress; near-zero weights ignore.