Foundations to Frontier
Tests
E. Deep Learning › E0 Core Concepts (concept pages)

The Artificial Neuron and Computation Graphs

An artificial neuron computes a weighted sum of its inputs, adds a bias, and passes the result through an activation function. With a step activation it is a linear threshold unit: it splits its input space with a hyperplane, so it can compute AND, OR and NAND but not XOR. Wiring neurons together, and writing every arithmetic step as a node, gives a computation graph: a directed acyclic graph that is evaluated in topological order and is the data structure every deep-learning framework builds, both to compute outputs and, later, gradients. This page covers the neuron model and its biological inspiration, the geometry of a single neuron, building and evaluating computation graphs, parameter counting, and how layers and graphs relate. In the exercises you build neurons and a graph evaluator and assemble an XOR network from three neurons, then count exactly how many Boolean functions one neuron can compute as the number of inputs grows.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

A tiny decision maker

An artificial neuron takes several numbers, multiplies each by a weight that says how much it matters, adds them up with a bias, and then decides: if the total is high enough, it fires. Every deep network is millions of these simple units, wired into a computation graph that a computer evaluates step by step.

One neuron: a weighted sum, a bias and a threshold
target:
0001x1 →↑ x2x11x21× w1 (1.0)1.00× w2 (1.0)1.00Σ + b (-1.5)z = 0.50stepy = 1
4 of 4 corners match AND · graph evaluated at corner (1, 1) — click a corner to change it
The neuron splits the plane with a straight line: one side outputs 1, the other 0 (the sigmoid blurs the edge). AND, OR and NAND each need only the right line. XOR needs the two diagonal corners on the same side and the other two on the opposite side, which no straight line can do, so at most 3 of 4 corners ever match. That limit is why networks stack neurons into layers.
Why engineers care

Flight software, perception stacks and onboard fault detectors increasingly contain neural networks. Underneath any framework, a network is a computation graph of weighted sums and activations. Knowing that structure is the basis for counting parameters and memory, checking what a model can and cannot represent, and later for differentiating it.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A neuron's output depends on…
  2. 2. A single step-activation neuron can compute…
  3. 3. A computation graph is evaluated…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The neuron by hand

Model. y = φ(z) with z = w·x + b = Σᵢ wᵢxᵢ + b. Here w is the weight vector, b the bias and φ the activation.

  • Step: φ(z) = 1 if z > 0, else 0.
  • Sigmoid: φ(z) = 1/(1 + e⁻ᶻ).

Example. For x = (1, 2, 3), w = (0.5, −1, 2) and b = 0.5: z = 0.5 − 2 + 6 + 0.5 = 5.

Logic gates with weights (1, 1). On binary inputs (each 0 or 1):

  • bias −1.5 fires only for (1, 1): AND;
  • bias −0.5 fires unless both are 0: OR;
  • weights (−1, −1) with bias 1.5 give NAND.

Parameters. A layer of k neurons on n inputs has k(n + 1) parameters (weights plus biases). For 100 neurons on a 28 × 28 image, that is 100 × 785 = 78 500.

Computation graph. Write each operation as a node: inputs and constants, multiplications, sums and activations. Edges show which values each node needs. One neuron with two inputs needs 2 multiplications, 1 sum (with the bias) and 1 activation.

📝 Quick check (Level 1)
0/3 answered
  1. 1. z for x = (2, 1), w = (1, −3), b = 1?
  2. 2. Parameters in a layer of 10 neurons on 5 inputs?
  3. 3. Weights (1, 1) with bias −1.5 on binary inputs give…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.

Geometry and graphs

A neuron is a hyperplane. The set w·x + b = 0 is a line in 2-D (a hyperplane in general). A step neuron outputs 1 on one side and 0 on the other, and the weight vector points toward the “1” side. So a single neuron can compute exactly the linearly separable functions.

XOR is not separable. It needs (0, 1) and (1, 0) on one side, and (0, 0) and (1, 1) on the other, which no straight line can do. Two layers can: XOR(x₁, x₂) = AND(OR(x₁, x₂), NAND(x₁, x₂)).

Evaluating a graph. Order the nodes so that each comes after its parents (a topological order, found by depth-first search or Kahn’s algorithm), then compute each node’s value from its parents’ values. Frameworks record this graph as you compute; it is reused for gradients (E0-3).

Exercise 1. Single neurons computed AND, OR and NAND. A graph of three neurons (OR and NAND feeding AND) computed XOR as (0, 1, 1, 0). Built from primitive nodes, that XOR network has 23 nodes:

  • 2 inputs and 9 constants (6 weights and 3 biases);
  • 6 multiplications, 3 sums and 3 step activations.
import torch, torch.nn as nn
layer = nn.Linear(2, 1)                 # weights w and bias b
y = (layer(torch.tensor([[1.0, 1.0]])) > 0).float()   # step activation
🐍 Exercise 1: neurons and a computation graph
Implement a neuron with step and sigmoid activations, a computation-graph Node class with topological ordering and forward evaluation, and build a 3-neuron XOR network out of primitive nodes.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The weight vector of a step neuron points…
  2. 2. XOR can be built as…
  3. 3. A topological order guarantees…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

McCulloch–Pitts and threshold logic. McCulloch and Pitts (1943) showed that networks of threshold units can compute any Boolean function. A two-layer network suffices (one hidden neuron per true input pattern, then an OR), but it may need exponentially many neurons.

Counting dichotomies. Cover (1965) counted how many of the 2ᵐ labelings of m points in general position in ℝᵈ a hyperplane through the origin can realise: C(m, d) = 2 Σₖ₌₀^(d−1) C(m − 1, k). For a neuron with bias on n inputs, d = n + 1. Points on the Boolean cube are not in general position, so the true counts are lower.

Capacity. For points in general position, a single neuron can realise all labelings of up to d points, and about half of them at m = 2d. This gives the classic “capacity of 2 bits per weight” (Cover, 1965; Gardner, 1988).

Graphs as programs. A computation graph is a directed acyclic graph. Evaluation is linear in the number of edges, and memory can be reduced by freeing values no later node needs. Static graphs (TensorFlow 1, XLA) are optimised before running. Dynamic graphs (PyTorch) are recorded as the code runs.

Interview questions.

  • Why must a computation graph be acyclic? So that each value depends only on earlier ones. Recurrences are unrolled in time into an acyclic graph (E11).
  • Why is a bias needed? Without it every decision hyperplane passes through the origin, and the input (0, 0) always gives z = 0. A step neuron then outputs 0 there, so functions such as NAND, which must output 1 at (0, 0), become impossible.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Cover's count C(m, d) applies to points…
  2. 2. Without a bias, a neuron's decision boundary…
  3. 3. PyTorch builds its graph…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

How much can one neuron compute?

History.

  • W. McCulloch and W. Pitts (1943) introduced the threshold neuron.
  • F. Rosenblatt (1958) introduced the perceptron.
  • T. Cover (1965) counted the dichotomies a hyperplane can realise.
  • M. Minsky and S. Papert (1969) analysed the limits of single-layer perceptrons, including XOR and parity.
  • Reverse-mode differentiation on computation graphs (Linnainmaa, 1970) later made multilayer training practical.

Exercise 2. Every Boolean function of n inputs was tested with the perceptron, run on all 2^(2ⁿ) functions at once for 60 epochs (a linearly separable function is learned exactly; others never are).

inputs n Boolean functions computable by one neuron share Cover bound (general position) worst-case epochs to converge
1 4 4 1.0000 4 3
2 16 14 0.8750 14 8
3 256 104 0.4062 128 19
4 65 536 1882 0.0287 3882 52
  • One neuron’s reach collapses with the number of inputs. It computes 14 of 16 functions of 2 inputs (only XOR and XNOR fail), but under 3% of the 65 536 functions of 4 inputs.
  • The cube is far from general position. For 4 inputs the true count is less than half of Cover’s bound. Many corners line up on common hyperplanes, which removes labelings.
  • Learning gets slower too. The worst separable function needed 52 passes for n = 4, against 3 for n = 1, because its margin is tiny.
  • Hence depth: layers of neurons compose these simple splits into functions no single neuron can represent.
🐍 Exercise 2 (research): Boolean functions one neuron can compute
Run the perceptron on every Boolean function of n = 1–4 inputs simultaneously, count the linearly separable ones, compare with Cover's general-position bound, and record the worst-case number of epochs.

Neurons and graphs in AI, robotics and aerospace

  • Model sizing: counting parameters and operations per layer, from the graph, to fit a network into flight-computer memory and timing budgets.
  • Certification and analysis: verification tools for neural controllers work directly on the computation graph of weighted sums and activations.
  • Hardware: FPGA and neuromorphic implementations map each neuron’s multiply–accumulate and activation onto circuits.

References

  1. W. S. McCulloch, W. Pitts (1943). “A logical calculus of the ideas immanent in nervous activity.” Bulletin of Mathematical Biophysics 5.
  2. F. Rosenblatt (1958). “The perceptron: a probabilistic model for information storage and organization in the brain.” Psychological Review 65(6).
  3. T. M. Cover (1965). “Geometrical and statistical properties of systems of linear inequalities with applications in pattern recognition.” IEEE Trans. Electronic Computers 14(3).
  4. M. Minsky, S. Papert (1969). Perceptrons. MIT Press.
  5. I. Goodfellow, Y. Bengio, A. Courville (2016). Deep Learning, chapter 6. MIT Press.