For the training process of a neural network, the backpropagation algorithm lies at its core. Based on the deviation between the predicted value and the actual value , the network computes the gradients of the loss function with respect to each parameter from back to front, and then uses gradient descent to optimize and train the network’s parameters.
The computation graph of the neural network is shown below:
The computation graph of the neural network: showing the gradient computation paths of each parameter in forward and backward propagation
From this computation graph, we can see that if we want to compute the network’s parameters , we first need to compute and , and then use the chain rule to obtain .
Next we compute and . Again, by the chain rule, we obtain as well as . This gives us and .
In addition, to compute and , we first need to compute , and . Again, by the chain rule, we obtain , as well as . This likewise gives us and .
When using stochastic gradient descent (SGD) as the optimization algorithm together with the cross-entropy loss function, we let , that is, the loss function:
Using the sigmoid activation function, that is,
Substituting this activation function and loss function into the computation above, we obtain:
During stochastic gradient descent, we randomly select a misclassified point from the samples, compute the current based on that point, and then use the following formulas to update :
until convergence.
For training neural networks, there are also methods such as batch gradient descent, mini-batch gradient descent, stochastic gradient descent with momentum, RMSProp, and Adam, which I will explain in detail later.