Repository navigation
Module 04
⬅️ Module 03 · 🗺️ Curriculum · 🏠 Home · Module 05 ➡️
Level: Beginner · Prerequisites: Module 01 (dot product, hyperplanes) · Time: about 5–6 hours
On this page: Overview and learning goals · Beginner: the big picture · Core concepts and derivations · Worked example · Implementation · Advanced topics · Pitfalls and best practices · Conceptual questions and answers · Sources and further reading
Neural networks began as mathematical models of neurons. This module follows the idea from biology, to the McCulloch–Pitts threshold unit, to Rosenblatt's learning perceptron, and ends with the XOR problem that shows why a single unit is not enough and motivates hidden layers (Module 07).
After this module you should be able to:
- describe the roles of dendrites, soma, axon and synapse and how they map to inputs, weights, summation and output;
- build AND, OR, NOT, NAND and NOR with threshold neurons;
- write the perceptron as a hyperplane classifier and run its learning rule by hand;
- state the perceptron convergence theorem and prove XOR is not linearly separable.
A biological neuron collects signals through dendrites, sums them in the cell body (soma), and if the total is large enough fires a spike along the axon; synapses are the connections whose strength can change with experience — the biological analogue of weights. An artificial neuron keeps only this skeleton: weighted sum, then threshold. This is a very loose abstraction; real neurons are spiking, dynamic and far more complex, so treat the analogy as inspiration, not explanation.
flowchart LR
x1["x1"] -->|"w1 (synapse)"| S["Sum: w.x + b (soma)"]
x2["x2"] -->|"w2"| S
x3["x3"] -->|"w3"| S
S --> T["Threshold: 1 if sum >= 0 (fire)"]
T --> Y["Output y (axon)"]
Excitatory synapses push the neuron toward firing, inhibitory ones away. In artificial units this is the sign of a weight:
The 1943 model takes binary inputs
With weights
| Function | Weights, bias (fires if |
|---|---|
| AND |
|
| OR |
|
| NOT |
|
| NAND |
|
| NOR |
|
NAND alone is functionally complete, so networks of threshold units can compute any Boolean function — but may need hidden layers.
A unit with weights
Rosenblatt's perceptron generalises to real weights and inputs:
For labels
Nothing changes when the prediction is correct. A false negative (

Figure 4.1 — AND has a separating line; no single line separates XOR. Original figure (figures/make_figs_1.py).
Novikoff (1962). If the data lie within radius
Proof sketch. After
If the data are not separable, the algorithm never converges — it cycles.
Suppose
Learn AND with
| Epoch | End weights |
End bias | Mistakes |
|---|---|---|---|
| 1 | (1, 1) | 0 | 2 |
| 2 | (2, 1) | −1 | 3 |
| 3 | (2, 1) | −2 | 3 |
| 4 | (2, 2) | −2 | 2 |
| 5 | (2, 1) | −3 | 1 |
| 6 | (2, 1) | −3 | 0 |
Final check:
import numpy as np
def train_perceptron(X, y, eta=1.0, epochs=100):
w, b = np.zeros(X.shape[1]), 0.0
for _ in range(epochs):
mistakes = 0
for xi, yi in zip(X, y):
yhat = int(w @ xi + b >= 0)
if yhat != yi:
w += eta * (yi - yhat) * xi; b += eta * (yi - yhat); mistakes += 1
if mistakes == 0: break
return w, b
X = np.array([[0,0],[0,1],[1,0],[1,1]]); print(train_perceptron(X, np.array([0,0,0,1]))) # AND
print(train_perceptron(X, np.array([0,1,1,0]))) # XOR: never reaches 0 mistakes-
Margin and SVMs: among all separators, the maximum-margin one generalises best by margin bounds; the perceptron bound
$(R/\gamma)^2$ is the first such result. - Kernel perceptron: replace dot products with kernels to separate data nonlinearly.
- Averaged/voted perceptron improves stability for non-separable data.
- Logistic regression replaces the hard threshold with a sigmoid and a probabilistic loss, making training differentiable (Module 06).
- Cover's theorem: data in a high-dimensional feature space are more likely linearly separable; hidden layers learn such features.
- Minsky & Papert (1969) analysed limits of single-layer perceptrons (parity, connectedness), which contributed to the first "AI winter".
- Treating biological analogy as literal.
- Forgetting the bias term (the boundary is then forced through the origin).
- Running the perceptron on non-separable data and expecting convergence.
- Using
${0,1}$ and${-1,+1}$ label conventions inconsistently.
Q1. What is the role of the bias?
It shifts the decision hyperplane away from the origin; without it, every boundary passes through
Q2. How do excitatory and inhibitory inputs map to weights?
Positive weights are excitatory, negative weights inhibitory; magnitude is synaptic strength.
Q3. Why can a single perceptron not compute XOR?
XOR's positive and negative points cannot be separated by one hyperplane; the four linear inequalities are mutually inconsistent (proof above).
Q4. State the perceptron convergence theorem and its key assumption.
If the data are linearly separable with margin
Q5. Why does the update rule move $\mathbf{w}$ toward $\mathbf{x}$ on a false negative?
Adding
Q6. Why is NAND significant?
It is functionally complete: any Boolean function can be built from NAND gates, so threshold networks are universal for Boolean logic given enough depth.
Q7. What changes between the perceptron and logistic regression?
The hard step becomes a smooth sigmoid, the output a probability, the loss cross-entropy, and training uses gradients rather than mistake-driven updates.
Q8. What happens if you run the perceptron on non-separable data?
It never reaches zero mistakes; weights cycle indefinitely, so you need a stopping rule or a different algorithm.
- McCulloch, W. S., & Pitts, W. (1943). A logical calculus of the ideas immanent in nervous activity. Bulletin of Mathematical Biophysics, 5, 115–133.
- Rosenblatt, F. (1958). The perceptron: a probabilistic model for information storage and organization in the brain. Psychological Review, 65(6), 386–408.
- Novikoff, A. B. (1962). On convergence proofs on perceptrons. Symposium on the Mathematical Theory of Automata.
- Minsky, M., & Papert, S. (1969). Perceptrons. MIT Press.
⬅️ Module 03 · 🗺️ Curriculum · 🏠 Home · Module 05 ➡️
🏠 Home · 🗺️ Curriculum · 🧭 Learning paths · ❓ Question bank · 📖 Glossary · 📚 References · ✏️ Contributing
🏠 Home · 🗺️ Curriculum · 🧭 Learning paths
❓ Question bank · 📖 Glossary · 📚 References
Jump to module:
01 02 03 04 05 06 07 08 09 10 11 12
13 14 15 16 17 18 19 20 21 22 23 24