Keywords: backpropagation, BP
We have seen a three-layer network is flexible in approximating functions. If we had a more-than-three-layer network, it could be used to approximate any functions as close as we want. However, another trouble came to us is how to train these networks. This problem almost killed neural networks in the 1970s. Until backpropagation(BP for short) algorithm was found that it is an efficient algorithm in training multiple layers networks.
3-layer network is also used in this post for it is the simplest multiple-layer network whose abbreviated notation is:
and a more short way to represent its architecture is:
For the three-layer network has only three layers which is not too large to denote mathematically, then it can be writen as:
but, it becomes impossible when we have a 10-layer network or 100-layer network. Then we can use some short equations that describe the whole operation of -layer network:
for . is the number of layers in the neural networks. And:
- is its input
- is its output
We have had a network now. And ‘performance learning’ is a kind of learning rule in learning task. Then we need a definite performance index for the 3-layer network. MSE is used here as the performance index the same as what the LMS algorithm did in post ‘Widrow-Hoff Learning(Part I)’ and ‘Widrow-Hoff Learning(Part II)’. And a set of examples of proper network behavior are needed:
where is the input and is the corresponding output.
Recall that in the steepest descent algorithm, we have a definite objective function, minimizing which is the task of the algorithm iteratively. BP is the generation of LMS algorithms, and both of them try to minimize the mean square error. However, the best structure of the network that is the closest to the true data is unknown. So each iteration an approximation of ‘Error’ which was calculated from our observation was used in the algorithm. And what we finally get is a trained neural network that fits the training set but not guarantees fitting the original task. So a good training set which can represent the original task as close as possible is necessary.
To make it easier to understand from the steepest descent algorithm to LMS and BP, we convert the weights and bias in the neural network form and into a vector . Then the performance index is:
When network has multiple outputs this generalizes to:
During an iteration, in the LMS algorithm, MSE(mean square error) is approximated by SE(square error):
where the expectations are replaced by the calculation of current input, output, and target.
Reviewing the ‘steepest descent algorithm’, the approximate MSE which is also called stochastic gradient descent:
where is the learning rate.
However, the steep descent algorithm seems can not work on a multiple-layer network for we can not just calculate the partial derivative in the hidden layer and input layer directly. So we should recall another mathematical tool - chain rule.
when is explicit function of and is a explicit function of , we can calculate the partial derivative by:
The whole process looks like a chain. And let’s look at a simple example: when we have and , we have . We can easily calculate the direvative . And when chain rule is used, we have:
that is the same as what we get directly.
When the chain rule is used in the second part on the right of equation (8), we get the way to calculate the derivative of the weight of hidden layers:
from the abbreviated notation, we know that . Then equation (11) can be writen as:
Equation (12) could also be simplified by defining a new concept: sensitivity.
We define sensitivity as that means the sensitivity of to changes in the element of the net input at layer . Then equation (12) can be simplified as:
Then the steepest descent algorithm is:
This can also be written in a matrix form:
And be careful of the which means the sensitivity and which means the number of layers
Backpropagating the Sensitivities
Equation (15) is our BP algorithm. But we can not calculate sensitivities yet. We can easily calculate the sensitivities of the last layer which is the same as LMS. And we have an inspiration that is we can use the relation between the latter layer and current layer. So let’s observe the Jacobian matrix which represents the relation between the latter layer linear combination output and current layer linear combination output :
And the element of the matrix is:
where is the linear combination output of layer and is the output of layer . And we can define
Therefore the Jacobian matrix can be written as:
where we have:
Then recurrence relation for the sensitivity by using chain rule in matrix form is:
This is why it is called backpropagation, because the sensitivities of layer is calculated by layer :
Same to the LMS algorithm, BP is also an approximating algorithm of the steepest descent technique. And the start of BP is:
and this is easy to understand because it is just a variation of the LMS algorithm. Since
we can write:
and its matrix form is:
Summary of BP
- Propagate the input forward through the network
- Propagate the sensitivities backward through the network:
- Finally, the weights and bias are updated using the approximate steepest descent rule:
An example of BP algorithm
Here we look at a simple example. Considering the function:
Then the sampling process should be done. And we get same function values with some selected inputs 's, for example, we have a set of
then we get corresponding function values of are
So, we have had training data, and then we need to choose a network architecture. The following network would be used:
This 1-2-1 network is relatively simpler than other networks. And what we should do next is to choose initial values for the network weights and biases. They are usually chosen to be small random values. Here we chose all of these parameters from a uniform distribution over .
And the inputs are fed into the 1-2-1 network whose initial weights are:
and we get the output of the network are:
Now let’s start the algorithm step by step:
- we have the first input
- The output of the first layer is then
- The output of the second layer is:
- Because we have generated both the input and target in equation(3), we can calculate the error:
- We then backpropagate the sensitivities during which derivatives of transfer function are needed:
- Now we have all components which is required for backpropagating
- The starting point is found in the second layer:
- And the sensitivity of first layer is:
- Finally we update the weights. For similicity, we will use a learning rate :