What is the bias term in a neural network?
The bias is a learned number added to a neuron's weighted sum before the activation function, so the neuron computes σ(w·x + b). The weights set which direction the neuron responds to, and the bias sets where along that direction it switches on. Geometrically, the bias moves the neuron's decision boundary away from the origin.
Nearly every dense and convolutional layer has one bias per neuron, so a layer with n inputs and m neurons holds n×m weights and m biases. Without biases, every boundary in the first layer would have to pass through the origin, which fails as soon as the classes sit off-center. This explainer starts with one neuron and ends with a small network whose boundaries combine to solve XOR.
Key ideas
- A neuron computes σ(w·x + b); the bias b is learned just like the weights.
- The weights set the decision boundary's orientation, and the bias sets its offset.
- Without a bias, every boundary must pass through the origin.
- Each neuron draws one linear boundary; later layers combine them into curved regions.
- XOR needs at least two boundaries, so it needs at least one hidden layer.
- Biases add few parameters but let each neuron place its boundary anywhere.
Common questions
Do all neural network layers have a bias?
No. A layer followed by batch normalization usually drops its bias, because batch norm subtracts the mean and then adds its own learned shift. Some large language models, such as PaLM, remove biases from their dense layers entirely and report more stable training.
Is the bias term related to bias in the bias-variance tradeoff?
No, the shared word is a coincidence. The bias term is a parameter inside a neuron. Bias in the bias-variance tradeoff is a model's systematic error, caused by assumptions too simple to fit the data.
Can a decision boundary be curved?
A single neuron's boundary is always flat: a line, plane, or hyperplane. Curved boundaries come from combining many neurons in hidden layers, from adding non-linear features such as x₁² before a linear model, or from kernel methods such as an RBF support vector machine.
How is a decision boundary plotted for a trained model?
Evaluate the model on a fine grid of points covering the input space and color each point by its predicted class, as the shaded regions here do. The boundary is where the color changes. This only works directly for two input features; for more, plots fix the other features or project the data to 2D first.
Related explainers
- The Perceptron — The simplest neural network — one neuron, one decision boundary
- Neural Networks — Neurons, layers, and how networks learn
- Activation Functions — Why networks need non-linearity to learn
- Support Vector Machines — Maximum margin classifiers and the kernel trick
- Batch Normalization — Why normalizing activations speeds up deep network training
- Weight Initialization — Xavier, He, and why random weights matter
References
- Goodfellow, Bengio & Courville (2016), "Deep Learning", chapter 6: Deep Feedforward Networks (6.1: Learning XOR)
- Nielsen, "Neural Networks and Deep Learning", chapter 1
- Ioffe & Szegedy (2015), "Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift"
- Chowdhery et al. (2022), "PaLM: Scaling Language Modeling with Pathways"
Last updated