Neural Network Fundamentals · 15 min

What's a perceptron, really?

A single neuron is three numbers and a threshold. It computes a weighted sum, compares it to zero, and answers yes or no. Geometrically, it draws a line.

0 / 0

Three numbers and a threshold

You’ve heard a neural network is made of “neurons,” and you’ve probably seen the cartoon: a blob with wires going in, modelled on a brain cell. Set the biology aside right now. A real cortical neuron has thousands of synapses, dendritic compartments, and messy chemistry. The thing in a neural network is not that.

The thing in a neural network is this: take some input numbers, multiply each by a weight, add them up, add one more number, and check whether the result cleared zero. That’s the whole unit. It’s called a perceptron, and the only reason it’s called a “neuron” is that someone in 1943 thought the analogy was cute. The analogy will cost you later. Drop it now.

What’s left is arithmetic. Let’s look at it.

The weighted sum

A perceptron with two inputs holds three numbers: two weights w1,w2w_1, w_2 and a bias bb. Hand it an input x=(x1,x2)x = (x_1, x_2) and it computes one scalar:

z  =  w1x1+w2x2+b  =  wx+b.z \;=\; w_1 x_1 + w_2 x_2 + b \;=\; w \cdot x + b.

That’s a dot product plus an offset. Nothing you haven’t seen. We’ll call zz the pre-activation: the number the neuron has before it decides anything.

Below, the four corners of the unit square are a tiny dataset. Three are class 0, one is class 1 (this is the logical AND). The red line is the perceptron’s boundary. Drag its two handles around and watch the weights and bias change.

-112-112
4 / 4 correct ✓ separated
w₁ = 0.71 w₂ = 0.71 b = -1.06 decision: w·x + b ≥ 0

Notice you never typed a weight. You moved a line, and w1,w2,bw_1, w_2, b came along for the ride. Hold onto that.

Compute a pre-activation

A perceptron has weights w=(1,1)w = (1, 1) and bias b=1.5b = -1.5. You feed it the input x=(1,1)x = (1, 1).

What is the pre-activation z=wx+bz = w \cdot x + b?

The threshold turns a number into a decision

The pre-activation zz is just a number. The perceptron’s actual output is a yes/no, and it gets there with a hard threshold at zero:

y  =  step(z)  =  {1z00z<0y \;=\; \text{step}(z) \;=\; \begin{cases} 1 & z \ge 0 \\ 0 & z < 0 \end{cases}

So the input (1,1)(1,1) with z=0.5z = 0.5 comes out as class 1. The other three corners of the AND square produce a negative zz and come out as class 0. One neuron, four inputs, correct on all of them.

The threshold is doing something quietly important: it splits every possible input into exactly two camps, the ones that clear zero and the ones that don’t. The dividing wall between those camps is where the next idea lives.

A perceptron is a line

The wall is the set of inputs where the perceptron is exactly on the fence: z=0z = 0, that is

wx+b=0.w \cdot x + b = 0.

In two dimensions, that equation is a straight line. (In three dimensions it’s a plane; in nn dimensions, a hyperplane. Same object, more axes.) Everything on one side is class 1, everything on the other is class 0. The shaded region in the widget is the class-1 side.

This is the whole geometric story of a single neuron: it picks a line and answers “which side are you on?” The weights ww control the line’s tilt (the vector ww points perpendicular to it). The bias bb controls how far the line sits from the origin.

Drag the handles again, this time watching only the line. Every position is a different perceptron.

Place the boundary

You keep the weights w=(1,1)w = (1, 1) and want the decision boundary to pass exactly through the point (0.5, 0.5)(0.5,\ 0.5).

A point is on the boundary when wx+b=0w \cdot x + b = 0.

What bias bb puts the boundary through (0.5,0.5)(0.5, 0.5)?

Why the bias is not optional

A tempting instinct: ”bb is a small correction, start it at zero.” Try it. Set b=0b = 0 in wx+b=0w \cdot x + b = 0 and the boundary becomes wx=0w \cdot x = 0, which is the set of points perpendicular to ww through the origin. The line is now nailed to (0,0)(0,0).

A line forced through the origin cannot separate the AND dataset. The one class-1 point is the far corner (1,1)(1,1); the three class-0 points include (0,0)(0,0) itself. No line through the origin puts (1,1)(1,1) alone on one side. The bias is the only knob that lets the boundary miss the origin, and AND needs it to.

So bb is not a correction. It’s the parameter that decides whether the neuron can solve the problem at all.

Read off a classification

A perceptron has weights w=(3,2)w = (3, -2) and bias b=1b = 1. You feed it the input x=(0,0)x = (0, 0).

Compute zz, then apply the threshold.

Which class does it output, 0 or 1?

Training is just moving the line

Step back and look at what you’ve built. A perceptron is three numbers. Those three numbers are a line. Classifying an input is checking which side of the line it landed on.

So what would it mean to “train” this thing? It would mean nudging the line until the two classes sit cleanly on opposite sides. That’s it. No magic, no biology: training a perceptron is sliding a line into place.

Try it directly. Switch the widget to OR and drag the handles until all four points are correct. You just trained a perceptron by hand.

-112-112
4 / 4 correct ✓ separated
w₁ = 0.71 w₂ = 0.71 b = -1.06 decision: w·x + b ≥ 0

Here’s the catch that runs the rest of this module. A perceptron can only ever draw one straight line. Some datasets cannot be split by any straight line at all, no matter how you drag. The smallest, most famous such dataset broke the field’s confidence for over a decade. Next lesson, you meet it.

Lesson complete

Nice tinkering.