https://blog.csdn.net/goldfish288/article/details/79835550
Original Address: https: //mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/
And gradually reverse the spread of examples
background
Back propagation neural network is a common method of training, before this has been thorough enough understanding of this article let me be completely get to know the details of the back-propagation.
Overview
For this tutorial, we will use two inputs, two hidden neurons, two output neurons of the neural network. In addition, hidden and output neurons will include a bias.
The basic structure is as follows:
In order to use some numbers, here is the initial weight, prejudice and training inputs / outputs:
Goal back propagation is to optimize the weight, so that the neural network can learn how to properly map any input to the output.
For the remainder of this tutorial, we will use a single training set: 0.05 and 0.10 for a given input, the output of the neural network we want 0.01 and 0.99.
Forward Pass
First, let's take a look at the neural network to predict what is currently given 0.05 and 0.10 of weights and bias. To this end, we will feed these inputs through the network forward.
We calculate the total net input to each hidden layer neuron activation function of the total input net (here we use the logical function) Squash and then repeat the above process with the output neuron layer.
Here's how we calculate the total net investment :
Then we use the logic function to compress it in order to get the following output :
Follow the same procedure, we get:
We repeat this process for the output layer neurons, using the output of the hidden layer neurons as input.
Here is the output :
And performs the same process, we get:
Calculation of the error
现在我们可以使用平方误差函数来计算每个输出神经元的误差,并将它们相加得到总误差:
例如,目标输出为0.01,但神经网络输出为0.75136507,因此其误差为:
重复这个过程(记住目标是0.99),我们得到:
神经网络的总误差是这些误差的总和:
向后传递
我们使用反向传播的目标是更新网络中的每个权重,使它们使实际输出更接近目标输出,从而最大限度地减少每个输出神经元和整个网络的误差。
输出层
考虑一下。我们想知道变化会影响总误差,也就是说。
通过应用链式规则,我们知道:
在视觉上,这是我们正在做的事情:
我们需要找出这个方程中的每一部分。
首先,总误差相对于输出的变化有多大?
接下来,相对于其总净投入的变化输出多少?
最后,关于变化的总净投入是多少?
把它放在一起:
为了减少误差,我们从当前权重中减去这个值(可选地乘以一些学习率eta,我们将其设置为0.5):
我们可以重复这个过程中获得新的权重,以及:
在我们将新权重引入隐含层神经元之后,我们执行神经网络中的实际更新(即,当我们继续下面的反向传播算法时,我们使用原始权重,而不是更新的权重)。
隐藏层
接下来,我们将继续为新的计算值,向后传递,,,和。
大图片,这是我们需要弄清楚的:
视觉:
我们将使用与输出层类似的过程,但略有不同,以说明每个隐藏层神经元的输出对多个输出神经元的输出(并因此产生误差)的贡献。我们知道这影响到两者,因此需要考虑它对两个输出神经元的影响:
从以下开始:
我们可以使用我们之前计算的值来计算:
并且等于:
将它们插入:
按照相同的过程,我们得到:
因此:
现在,我们有,我们需要弄清楚,然后每一个权重:
我们计算总净投入的偏导数,与我们对输出神经元所做的相同:
把它放在一起:
你也可以看到这写成:
我们现在可以更新:
重复这些,和
Finally, we have updated all the weight! When we first input of 0.05 and 0.1, the error in the network is 0.298371109. After the first round of back propagation, the total error is now reduced to 0.291027924. It may not seem like much, but after this process is repeated 10,000 times, the error would plummet to 0.0000351085. At this time, when we advance 0.05 and 0.1, two output neurons 0.015912196 (vs 0.01 objectives) and 0.984065734 (vs 0.99 objectives).
If you've done this, and found that any of the above error, or you can think of any method to make future readers more clearly, do not hesitate to give me a note . Thank you!