Layers, neurons and weights
A neural network is a model made of units called neurons, arranged in layers. The input layer holds the data, hidden layers transform it, and the output layer gives the prediction. Each connection between neurons carries a number called a weight.
Drawn as a graph, neurons are nodes and weights are edges. This shows how information flows from the inputs to the output.
What a single neuron computes
A neuron multiplies each input by its weight, adds the results and then adds a bias. The total goes through an activation function. ReLU, a common choice, returns the total if it is positive and zero otherwise.
Without a nonlinear activation, stacked layers would collapse into one linear function. The nonlinearity lets the network represent curved patterns.
Worked example: one forward pass and one update
Take inputs 2 and 1, weights 0.5 and 2, and bias -1. The sum is 2×0.5 + 1×2 - 1 = 2, and ReLU leaves 2. An output neuron with weight 3 and bias 1 predicts 2×3 + 1 = 7.
The target is 5, so the error is 7 - 5 = 2 and the squared error is 4. Backpropagation uses the chain rule to find how the loss changes with each weight. For the output weight the gradient is 2 × 2 × 2 = 8, where the last 2 is the hidden value.
With a learning rate of 0.1, the weight changes from 3 to 3 - 0.8 = 2.2. The new prediction is 2×2.2 + 1 = 5.4, and the squared error is 0.4 squared, which is 0.16.
Common misconceptions
Neural networks do not copy the brain. The neuron is only a loose analogy. A bigger network is not automatically better, because it can overfit, meaning it memorises the training data and predicts poorly on new data. Training is also different from running: training adjusts the weights, while prediction uses them unchanged.
Where neural networks are used
Neural networks are used for image recognition, speech recognition, language models and forecasting. Different architectures suit different data, such as convolutional networks for images. They usually need large datasets and much computation. On small tabular data, simpler models such as decision trees often perform comparably.
Key terms
- Neuron
- A unit that computes a weighted sum of its inputs plus a bias and applies an activation function.
- Weight
- A number on a connection that scales the signal passing through it and is learned during training.
- Bias
- A number added to a neuron's weighted sum that shifts its output.
- Activation function
- A nonlinear function, such as ReLU, applied to a neuron's sum.
- Loss
- A number measuring how far the network's predictions are from the targets.
- Backpropagation
- A method that uses the chain rule to compute the gradient of the loss with respect to every weight.
- Overfitting
- Fitting the training data so closely that performance on new data suffers.
