3.1.13Neural Network Fundamentals

Bias terms and their role

1,969 words9 min readdifficulty · medium

WHAT is a bias term?

  • x\mathbf{x} = input vector, w\mathbf{w} = weight vector (one weight per input).
  • bb does not multiply any input — it is a constant offset.
  • Every neuron in every layer has its own bias.

WHY do we need it? (Derivation from first principles)

Start with the simplest neuron and a linear activation ϕ(z)=z\phi(z)=z. With no bias: z=wx.z = w x. This is a line through the origin. At x=0x=0, we are stuck at z=0z=0. We can only rotate the line by changing ww; we can never move it up or down.

Now suppose the true relationship is y=2x+5y = 2x + 5. No matter what ww we pick, z=wxz = wx can never produce the constant +5+5. The model is fundamentally incapable of fitting the data.

Add a bias: z=wx+b.z = wx + b. Now bb supplies exactly the intercept. Setting w=2,b=5w=2, b=5 fits perfectly.

The absorbed-bias trick (why it's really just another weight)

Append a constant 11 to the input: x~=[x1,,xn,1]\tilde{\mathbf{x}} = [x_1,\dots,x_n,1], and let w~=[w1,,wn,b]\tilde{\mathbf{w}} = [w_1,\dots,w_n,b]. Then w~x~=iwixi+b1=z.\tilde{\mathbf{w}}^\top \tilde{\mathbf{x}} = \sum_i w_i x_i + b\cdot 1 = z. So the bias is mathematically the weight on a dummy input that is always 1. This is why it is trained by the same gradient descent rule as any weight.

Figure — Bias terms and their role

HOW is the bias learned? (Gradient derivation)

Let loss LL depend on output a=ϕ(z)a=\phi(z), z=wx+bz=\mathbf w^\top\mathbf x+b. By the chain rule: Lb=Laazzb.\frac{\partial L}{\partial b} = \frac{\partial L}{\partial a}\cdot\frac{\partial a}{\partial z}\cdot\frac{\partial z}{\partial b}. Now the key piece: zb=b(iwixi+b)=1.\frac{\partial z}{\partial b} = \frac{\partial}{\partial b}\Big(\sum_i w_i x_i + b\Big) = 1.

Update rule (learning rate η\eta): bbηδ.b \leftarrow b - \eta\,\delta.

For a whole minibatch of mm examples, gradients are summed/averaged: Lb=1mk=1mδ(k).\frac{\partial L}{\partial b}=\frac{1}{m}\sum_{k=1}^{m}\delta^{(k)}.


Worked Examples


Common Mistakes (Steel-manned)


Recall Checks

Recall Why can't a bias-free neuron represent

y=3y = 3 (constant)? Because z=wxz=\mathbf w^\top\mathbf x is zero whenever the input is zero and can't add a constant offset — every hyperplane it defines passes through the origin.

Recall What is

z/b\partial z/\partial b and why does it matter? It equals 11, so the bias gradient is simply the neuron's error δ\delta, independent of the input magnitude.

Recall What does

b/w-b/w represent for a sigmoid neuron? The input value at which the neuron is half-activated — its decision threshold.

Recall Feynman: explain to a 12-year-old

Imagine a light switch that turns on when you push it hard enough. The weights decide how much each push counts. The bias decides how hard the switch is to flip — a "loose" switch (big bias) turns on with a tiny push; a "stiff" one needs a big shove. Learning just means tightening or loosening that switch until the light turns on at exactly the right moments.


80/20 — the vital few

  1. z=wx+bz=\mathbf w^\top\mathbf x + b; bias is an added learnable offset per neuron.
  2. Without it, decision boundaries pass through the origin — huge loss of flexibility.
  3. L/b=δ\partial L/\partial b = \delta (because z/b=1\partial z/\partial b=1), trained by plain gradient descent.
  4. Bias sets the threshold (b/w-b/w); it shifts activations left/right.
  5. Init to 0, usually don't regularize it.

Connections


What is a bias term in a neuron?
A learnable scalar added to the weighted sum before activation: z=wx+bz=\mathbf w^\top\mathbf x+b; one per neuron.
Why is a bias necessary?
It lets the neuron shift its output/threshold so the decision boundary need not pass through the origin, enabling nonzero intercepts.
What is z/b\partial z/\partial b?
Exactly 11, since bb is added and doesn't multiply any input.
What is the bias gradient L/b\partial L/\partial b?
The neuron's error signal δ=L/z\delta=\partial L/\partial z (input-independent), unlike weight gradients δxi\delta x_i.
Bias as a weight — what's the trick?
Append a constant input of 11; the bias becomes the weight on that dummy input.
What does b/w-b/w mean for a sigmoid neuron?
The input value where the neuron is half-activated — its threshold.
How are biases usually initialized?
To 0 (small positive constant sometimes for ReLU); symmetry-breaking isn't needed for biases.
Should biases be L2-regularized?
Usually no — they add negligible capacity and penalizing them only harms the model's ability to set output means.
Weights vs bias roles?
Weights control slope/orientation of the boundary; bias controls its offset/threshold.
For a layer of H neurons, what is the bias shape?
A vector in RH\mathbb R^H — one bias per neuron.

Concept Map

weighted sum

weighted sum

added offset

apply phi

feeds

without it

cannot fit intercept

defines

weight on dummy input 1

same GD rule

chain rule dz/db = 1

updates

Input vector x

Weight vector w

Bias b scalar per neuron

Pre-activation z

Activation output a

Loss L

Line through origin

Decision threshold negative b

Absorbed-bias trick

Bias gradient equals delta

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek neuron basically inputs ka weighted sum leta hai: z=w1x1+w2x2++bz = w_1x_1 + w_2x_2 + \dots + b. Yeh jo bb hai, isko bias kehte hain. Weights decide karte hain ki line kitni tilt hogi, lekin bias decide karta hai ki line upar-neeche kahan set hai. Agar bias na ho, toh jab saare inputs zero honge, output bhi zabardasti zero ho jayega — matlab decision boundary hamesha origin se guzregi. Yeh ek badi limitation hai, kyunki real data ka intercept zero nahi hota.

Sochiye ek light switch — weights batate hain ki har push kitna count karta hai, aur bias batata hai ki switch kitna "tight" ya "loose" hai. Bada positive bias = switch aasani se on ho jata hai (neuron jaldi fire karta hai). Bada negative bias = zyada push chahiye. Sigmoid neuron mein neuron half-on hota hai jab x=b/wx = -b/w, yani bias threshold ko left-right slide karta hai.

Training kaise hoti hai? Chain rule se: z/b=1\partial z/\partial b = 1 hota hai (kyunki bias sirf add hota hai, kisi input ko multiply nahi karta). Isliye bias ka gradient seedha neuron ka error δ\delta ban jata hai — input ke size se independent. Ek pyaara trick: ek dummy input 11 jod do, toh bias bas usska weight ban jata hai, isliye same gradient descent se train hota hai.

Practical points: har neuron ka apna alag bias hota hai (poore layer ke liye ek nahi). Bias ko aksar 00 se initialize karte hain, aur usually L2 regularization mein include nahi karte, kyunki wo model ki flexibility ko bina fayde ke maar deta hai. Bas yaad rakho: weights tilt karte hain, bias budge karta hai.

Go deeper — visual, from zero

Test yourself — Neural Network Fundamentals

Connections