2. How the backpropagation algorithm works
Activation $a^l_j $ of the neuron in the l layer is related by:
Vectorization will simply it as:
The goal of backpropagation is to compute the partial derivatives of the cost function with respect to any weight or bias in the network.
Two assumptions are the cost function is:
- an average over individual cost function
- a function of the output activations from the neural network.
The error of a neuron is defined as:
where z is the weighted output. We didn’t use to have a simpler math.
backpropagation based on 4 fundamental equations
- error in the output layer(last layer): or
- error connected to next layer:
- error is the rate of change of the cost with respect to bias:
- rate of change of the cost with respect to weight:
- input x: get activation for input layer
- Feedforward: get weighted input and activation for other layers
- Output error: compute the error in the last layer by equation 1
- Backpropagate the error: using equation 2
- Output: get gradient of the cost function by equation 3 and 4.
The backward movement is a consequence of the fact that the cost is a cunction of outputs from the network.
The backpropagatino algorithm is a clever way of keeping track of small perturbation to the weights/biases as they propagate through the network, reach the output, and then affect the cost.