GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Module 04

Module 04

Jump to bottom
Anurag Prasad edited this page Nov 9, 2026 · 10 revisions

Module 04 — Biological Neurons, McCulloch–Pitts Neurons and Perceptrons

⬅️ 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


Overview and learning goals

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.

Beginner: the big picture

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)"]
Loading

Core concepts and derivations

Biological neuron and excitatory/inhibitory inputs

Excitatory synapses push the neuron toward firing, inhibitory ones away. In artificial units this is the sign of a weight: $w_i>0$ excitatory, $w_i<0$ inhibitory.

McCulloch–Pitts threshold neuron

The 1943 model takes binary inputs $x_i\in\{0,1\}$ and fires when the excitatory count reaches a threshold $\theta$, unless any inhibitory input is active (absolute veto):

$$y=\mathbf{1}\!\left[\sum_ix_i\ge\theta\right]\ \text{(and no inhibitory input active).}$$

Boolean functions

With weights $w_i=1$ and bias $b=-\theta$:

Function Weights, bias (fires if $\mathbf{w}^\top\mathbf{x}+b\ge0$)
AND $w=(1,1)$, $b=-2$
OR $w=(1,1)$, $b=-1$
NOT $w=-1$, $b=0$
NAND $w=(-1,-1)$, $b=1$
NOR $w=(-1,-1)$, $b=0$

NAND alone is functionally complete, so networks of threshold units can compute any Boolean function — but may need hidden layers.

Geometric decision boundaries and hyperplanes

A unit with weights $\mathbf{w}$ and bias $b$ splits input space by the hyperplane $\mathbf{w}^\top\mathbf{x}+b=0$. The vector $\mathbf{w}$ is normal to it, and the signed distance of a point is $(\mathbf{w}^\top\mathbf{x}+b)/\lVert\mathbf{w}\rVert$. The bias shifts the plane away from the origin.

Perceptron with real-valued inputs, vector form

Rosenblatt's perceptron generalises to real weights and inputs: $\hat y=\mathbf{1}[\mathbf{w}^\top\mathbf{x}+b\ge0]$. Absorbing the bias via $\tilde{\mathbf{x}}=(1,\mathbf{x})$, $\tilde{\mathbf{w}}=(b,\mathbf{w})$ gives $\hat y=\mathbf{1}[\tilde{\mathbf{w}}^\top\tilde{\mathbf{x}}\ge0]$.

Perceptron learning algorithm

For labels $y\in\{0,1\}$ and learning rate $\eta>0$, on each example:

$$\mathbf{w}\leftarrow\mathbf{w}+\eta\,(y-\hat y)\,\mathbf{x},\qquad b\leftarrow b+\eta\,(y-\hat y).$$

Nothing changes when the prediction is correct. A false negative ($y=1,\hat y=0$) moves $\mathbf{w}$ toward $\mathbf{x}$, increasing its score; a false positive moves it away.

AND is linearly separable; XOR is not

Figure 4.1 — AND has a separating line; no single line separates XOR. Original figure (figures/make_figs_1.py).

Linear separability and the convergence theorem

Novikoff (1962). If the data lie within radius $R$ ($\lVert\tilde{\mathbf{x}}\rVert\le R$) and some unit vector $\mathbf{w}^\star$ separates them with margin $\gamma$ ($y_i'\,\mathbf{w}^{\star\top}\tilde{\mathbf{x}}_i\ge\gamma$ with $y'=\pm1$), the perceptron makes at most $(R/\gamma)^2$ mistakes.

Proof sketch. After $k$ mistakes, each update adds $y'\tilde{\mathbf{x}}$ to $\mathbf{w}$, so $\mathbf{w}_k^\top\mathbf{w}^\star\ge k\gamma$. Also $\lVert\mathbf{w}_{k}\rVert^2\le\lVert\mathbf{w}_{k-1}\rVert^2+R^2$ (the cross term is $\le0$ on a mistake), so $\lVert\mathbf{w}_k\rVert^2\le kR^2$. Combining with Cauchy–Schwarz, $k\gamma\le\lVert\mathbf{w}_k\rVert\le\sqrt kR$, hence $k\le(R/\gamma)^2$. ∎

If the data are not separable, the algorithm never converges — it cycles.

XOR is not linearly separable

Suppose $\mathbf{w}=(w_1,w_2)$, $b$ solve XOR. Then $b<0$ (for $(0,0)$), $w_1+b\ge0$, $w_2+b\ge0$, and $w_1+w_2+b<0$. Adding the middle two: $w_1+w_2+2b\ge0$, so $w_1+w_2+b\ge-b>0$, contradicting the last. ∎ A hidden layer fixes this (Worked example, Module 05, Module 07).

Worked example

Learn AND with $\eta=1$, starting at $\mathbf{w}=(0,0)$, $b=0$, cycling through $(0,0),(0,1),(1,0),(1,1)$:

Epoch End weights $\mathbf{w}$ 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: $(1,1)\to2+1-3=0\ge0$ fires; $(1,0)\to-1$, $(0,1)\to-2$, $(0,0)\to-3$ do not. ✓ (The long wandering is typical: the perceptron stops at a separator, not the best one.)

Implementation

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

Advanced topics

  • 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".

Pitfalls and best practices

  • 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.

Conceptual questions and answers

Q1. What is the role of the bias?

Show answer

It shifts the decision hyperplane away from the origin; without it, every boundary passes through $\mathbf{0}$ and many simple functions (e.g. AND) are unreachable.

Q2. How do excitatory and inhibitory inputs map to weights?

Show answer

Positive weights are excitatory, negative weights inhibitory; magnitude is synaptic strength.

Q3. Why can a single perceptron not compute XOR?

Show answer

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.

Show answer

If the data are linearly separable with margin $\gamma$ and bounded by radius $R$, the algorithm makes at most $(R/\gamma)^2$ mistakes. The key assumption is linear separability.

Q5. Why does the update rule move $\mathbf{w}$ toward $\mathbf{x}$ on a false negative?

Show answer

Adding $\eta\mathbf{x}$ increases $\mathbf{w}^\top\mathbf{x}$ by $\eta\lVert\mathbf{x}\rVert^2>0$, pushing the score above the threshold.

Q6. Why is NAND significant?

Show answer

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?

Show answer

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?

Show answer

It never reaches zero mistakes; weights cycle indefinitely, so you need a stopping rule or a different algorithm.

Sources and further reading

  • 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

🎓 Deep Learning Hub

🏠 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

Part 1 · Mathematical foundations
  • 01 · Linear algebra & tensors
    Core · Advanced · Q&A
  • 02 · Calculus & autodiff
    Core · Advanced · Q&A
  • 03 · Probability & information theory
    Core · Advanced · Q&A
Part 2 · Neural network fundamentals
  • 04 · Neurons & perceptrons
    Core · Advanced · Q&A
  • 05 · Activations & expressivity
    Core · Advanced · Q&A
  • 06 · Losses & gradient descent
    Core · Advanced · Q&A
  • 07 · MLPs & backpropagation
    Core · Advanced · Q&A
Part 3 · Training deep networks
  • 08 · Optimization & loss landscapes
    Core · Advanced · Q&A
  • 09 · Initialization & normalization
    Core · Advanced · Q&A
  • 10 · Regularization & generalization
    Core · Advanced · Q&A
Part 4 · Core architectures
  • 11 · Convolutional networks
    Core · Advanced · Q&A
  • 12 · RNN, LSTM & GRU
    Core · Advanced · Q&A
  • 13 · Seq2seq & attention
    Core · Advanced · Q&A
  • 14 · Transformers
    Core · Advanced · Q&A
  • 15 · Positional encoding & attention variants
    Core · Advanced · Q&A
Part 5 · Representation and generative learning
  • 16 · Autoencoders
    Core · Advanced · Q&A
  • 17 · Self-supervised & contrastive
    Core · Advanced · Q&A
  • 18 · Variational autoencoders
    Core · Advanced · Q&A
  • 19 · GANs
    Core · Advanced · Q&A
  • 20 · Diffusion models
    Core · Advanced · Q&A
Part 6 · Specialised, modern and responsible deep learning
  • 21 · Graph neural networks
    Core · Advanced · Q&A
  • 22 · Transfer & foundation models
    Core · Advanced · Q&A
  • 23 · LLMs & multimodal
    Core · Advanced · Q&A
  • 24 · Evaluation, robustness & efficiency
    Core · Advanced · Q&A
Reference and meta
  • Math notation cheat sheet
  • Cross-module concept map
  • Figures and attribution
  • Implementation and research standards
  • Notebook roadmap
  • Source coverage
  • Contributing
  • Changelog

Clone this wiki locally

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.