Abstract
A neuron is a tiny calculator. Numbers go in, it adds them up with weights, and one number comes out. We tried 7 kinds on three tiny puzzles (AND, OR, XOR). The kind didn't matter much. What mattered was having more than one neuron working together.
Research question
Does the kind of neuron change what it can learn, or does only the number of neurons matter?
Hypothesis
- Every single neuron will solve AND and OR.
- Every single neuron will fail XOR.
- Two or more neurons together will fix XOR.
Why this matters
"Neuron" sounds complicated, but it isn't. Putting 7 kinds side by side on the same puzzles shows what changes between simple and advanced, and what doesn't.
Experimental setup
What a neuron does:
- Multiply each input by its own weight.
- Add everything up, plus one extra number called the bias.
- Optionally, pass the total through a "squash" step.
The 7 kinds differ only in step 3.
| # | Kind | Squash step |
|---|---|---|
| 1 | Step | 1 if total > 0, else 0 |
| 2 | Linear | Nothing, passes the total through |
| 3 | Sigmoid | Squeezes into 0 to 1 |
| 4 | Tanh | Squeezes into -1 to 1 |
| 5 | ReLU | Keeps positives, negatives become 0 |
| 6 | Group of 2 | 2 tanh neurons feed 1 sigmoid neuron |
| 7 | Group of 4 | 4 tanh neurons feed 1 sigmoid neuron |
The three puzzles (two inputs, each 0 or 1):
| Inputs | AND | OR | XOR |
|---|---|---|---|
| 0, 0 | 0 | 0 | 0 |
| 0, 1 | 0 | 1 | 1 |
| 1, 0 | 0 | 1 | 1 |
| 1, 1 | 1 | 1 | 0 |
Why one neuron can't do XOR. Draw the 4 inputs as points on a grid. Mark the points whose answer is 1 with ●, and the points whose answer is 0 with ○.
AND OR XOR
x2 x2 x2
1 ○ ● 1 ● ● 1 ● ○
0 ○ ○ 0 ○ ● 0 ○ ●
0 1 x1 0 1 x1 0 1 x1For AND and OR, one straight line can put the ● on one side and the ○ on the other. For XOR, the ● sit on opposite corners, so no single straight line can split them. One neuron draws one line, which is why it fails.
Settings:
- Kinds 2 to 5: learning speed 0.5, 2000 rounds
- Kind 1 (step): speed 0.1, 200 rounds
- Kinds 6 and 7: speed 0.5, 5000 rounds
- Random starting weights, with 10 different starts per kind per puzzle
- "Solved" means all 4 answers are right
Method
Plain numpy. Every round, each neuron nudges its weights a little to make its mistakes smaller.
import numpy as np
X = np.array([[0,0],[0,1],[1,0],[1,1.]])
tasks = {"AND": np.array([0,0,0,1.]),
"OR": np.array([0,1,1,1.]),
"XOR": np.array([0,1,1,0.])}
sig = lambda z: 1/(1+np.exp(-z))
acts = { # (squash, how fast it changes)
"linear": (lambda z: z, lambda z,o: np.ones_like(z)),
"sigmoid": (sig, lambda z,o: o*(1-o)),
"tanh": (np.tanh, lambda z,o: 1-o**2),
"relu": (lambda z: np.maximum(z,0),lambda z,o: (z>0)*1.),
}
def single(act, t, seed, lr=0.5, ep=2000):
r = np.random.default_rng(seed); w = r.normal(0,1,2); b = 0.
f, df = acts[act]
for _ in range(ep):
z = X@w + b; o = f(z); g = 2*(o-t)/4*df(z,o)
w -= lr*X.T@g; b -= lr*g.sum()
return np.mean((f(X@w+b) > 0.5) == t)
def step(t, seed, lr=0.1, ep=200):
r = np.random.default_rng(seed); w = r.normal(0,1,2); b = 0.
for _ in range(ep):
for x, y in zip(X, t):
o = float(x@w + b > 0)
w += lr*(y-o)*x; b += lr*(y-o)
return np.mean((((X@w+b) > 0)*1.) == t)
def group(h, t, seed, lr=0.5, ep=5000):
r = np.random.default_rng(seed)
W1 = r.normal(0,1,(2,h)); b1 = np.zeros(h)
W2 = r.normal(0,1,(h,1)); b2 = 0.
for _ in range(ep):
a = np.tanh(X@W1+b1); o = sig(a@W2+b2)[:,0]
g2 = (2*(o-t)/4*o*(1-o))[:,None]
g1 = (g2@W2.T)*(1-a**2)
W2 -= lr*a.T@g2; b2 -= lr*g2.sum()
W1 -= lr*X.T@g1; b1 -= lr*g1.sum(0)
o = sig(np.tanh(X@W1+b1)@W2+b2)[:,0]
return np.mean((o > 0.5) == t)
def report(name, fn):
out = [sum(fn(t,s)==1 for s in range(10)) for t in tasks.values()]
print(f"{name:18s} AND {out[0]}/10 OR {out[1]}/10 XOR {out[2]}/10")
report("step", lambda t,s: step(t,s))
for a in acts: report(a, lambda t,s,a=a: single(a,t,s))
report("group of 2", lambda t,s: group(2,t,s))
report("group of 4", lambda t,s: group(4,t,s))Results
How many of the 10 random starts got all 4 answers right:
| Kind | AND | OR | XOR |
|---|---|---|---|
| 1. Step | 10/10 | 10/10 | 0/10 |
| 2. Linear | 10/10 | 10/10 | 0/10 |
| 3. Sigmoid | 10/10 | 10/10 | 0/10 |
| 4. Tanh | 10/10 | 10/10 | 0/10 |
| 5. ReLU | 3/10 | 5/10 | 0/10 |
| 6. Group of 2 | 10/10 | 10/10 | 7/10 |
| 7. Group of 4 | 10/10 | 10/10 | 9/10 |
Analysis
- Kinds 1 to 4 behaved the same. All solved AND and OR every time, and none ever solved XOR. Changing the squash step gave no new power.
- XOR only became solvable with a group. 2 neurons got it 7 times out of 10, and 4 neurons got it 9 times out of 10.
- So the jump from simple to advanced is not a fancier single neuron. It's using several neurons together.
What we learned
- One neuron draws one straight line. That's enough for AND and OR, but not for XOR.
- The squash step matters for other reasons (output range, smooth learning), but it doesn't make one neuron smarter.
- Several neurons together can do what one can't.
Limitations
- Only 4 data points and 3 puzzles. Real problems are much bigger.
- One learning speed and one round count per kind. Other settings could change the scores.
- 10 starts is a small sample, so 7/10 vs 9/10 is a hint, not proof.
- Only 7 kinds tested. Real networks use many more.
Failures and surprises
ReLU did worst of the single neurons: only 3/10 on AND and 5/10 on OR. We didn't check why. A likely reason is that in some starts the total is negative for every input, so ReLU outputs 0 every time and stops learning. That's a guess until we test it.
Next question
Why did ReLU fail in some starts? Print its total for each input at the start of every failed run and check whether it was stuck at 0 (EXP-007).
References
- Rosenblatt (1958). The perceptron: a probabilistic model for information storage and organization in the brain. Psychological Review 65(6).
- Rumelhart, Hinton, Williams (1986). Learning representations by back-propagating errors. Nature 323, 533-536.
Tags: neuron, neural network basics, step, sigmoid, tanh, relu, hidden layer, XOR


