Skip to main content
Luxara Academy

Archive — one question answered

Weights and bias in one neuron

What does z = w·x + b mean when filtering spam?

One neuron computes a weighted sum plus bias. For features x=(2,0,1)\mathbf{x} = (2, 0, 1), weights w=(0.8, −0.5, 2.0)\mathbf{w} = (0.8,\,-0.5,\,2.0) and b=−1.5b = -1.5:

z=0.8×2+(−0.5)×0+2.0×1−1.5=2.1z = 0.8 \times 2 + (-0.5) \times 0 + 2.0 \times 1 - 1.5 = 2.1

The sign of each weight tells the direction: w2=−0.5w_2 = -0.5 on link count — more links pull zz down in the course spam example. w3=2.0w_3 = 2.0 on unknown sender is the strongest cue.

Changing bb from −1.5-1.5 to +1.0+1.0 while keeping w\mathbf{w} adds 2.52.5 to every zz: bias shifts the threshold for all emails, even when x=0\mathbf{x} = \mathbf{0}. Beginners often treat bias as a fourth weight — but bb is always added.

In training code, w\mathbf{w} and bb are parameters updated by gradient descent. Separating them helps you read a spam model as something inspectable, not a black box. After training, plotting w\mathbf{w} next to feature names shows which words the model actually learned to fear — the course’s first “interpretability” win. Lesson two walks through the same w\mathbf{w}, x\mathbf{x}, and bb numbers on the toy inbox so you can trace every multiplication on paper.