Multilayer Perceptrons › From Single Neurons to Hidden Layers
Language AI HandbookAll chapters Multilayer Perceptrons › From Single Neurons to Hidden LayersOne section · Sections in this chapter2 / 13 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
A single neuron computes a weighted sum of its inputs, adds a bias, and passes the result through an activation function. Given an input vector with features, the neuron computes:
where:
- : the input vector containing features
- : the weight vector, where each controls how much input influences the output
- : the dot product , computing a weighted sum of inputs
- : the bias term, which shifts the decision boundary
- : the activation function (e.g., ReLU, sigmoid), which introduces non-linearity
- : the scalar output of the neuron
This single neuron can learn a linear decision boundary (made non-linear by ), but it cannot solve problems requiring more complex boundaries.
A hidden layer is a collection of neurons that sits between the input and output of a neural network. Each neuron in a hidden layer receives the full input (or the output of the previous layer), applies its own weights and bias, and produces one scalar output. The term "hidden" reflects that these intermediate computations are not directly observed, only the final output layer is.
The XOR Problem
Consider the classic XOR problem: given two binary inputs, output 1 if exactly one input is 1, and 0 otherwise. No single linear boundary can separate the positive from negative examples. But with a hidden layer, we can first transform the inputs into a new representation where the classes become linearly separable.
The XOR truth table is:
| XOR output | ||
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
No matter how you try to draw a straight line through the four points, some misclassification will remain. XOR requires a non-linear boundary, and that is exactly what a hidden layer provides.
import numpy as np
# XOR inputs and outputs
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 0])
The magic happens when we add a hidden layer. Each hidden neuron learns to detect a different feature or pattern in the input. The output layer then combines these learned features to make the final prediction.
To see this in action, let's manually construct a hidden layer that solves XOR and visualize how it transforms the input space:


The hidden layer has transformed the input space so that a simple linear classifier can now separate the classes. The first hidden neuron activates only when both inputs are high (AND-like behavior), while the second activates when either input is high (OR-like behavior). In this new coordinate system, the XOR pattern becomes trivially separable.