反向传播算法(BP算法)

利用反向传播算法对神经网络进行训练。该方法与梯度下降算法相结合,对网络中所有权重计算损失函数的梯度,并利用梯度值来更新权值以最小化损失函数。在介绍BP算法前,我们先看下前向传播与链式法则的内容。

前向传播是指数据输入的神经网络,它被逐层传输,直到操作到达输出层。

[En]

Forward propagation refers to the neural network of data input, which is transmitted layer by layer until the operation reaches the output layer.

在网络的训练过程中经过前向传播后得到的最终结果跟训练样本的真实值总是存在一定误差,这个误差便是损失函数。想要减小这个误差,就用损失函数ERROR,从后往前,依次求各个参数的偏导,这就是反向传播(Back Propagation)。

反向传播算法使用链式规则来求解梯度并更新权值。对于复杂的复合函数,我们将其分解为一系列的初等函数,如加、减、乘、除或指数、对数、三角函数,并通过链规则完成复合函数的求导。为简单起见,以神经网络中常见的复合函数为例说明了这一过程。将复合函数𝑓(𝑥;𝑤,𝑏)设置为:

[En]

The back propagation algorithm uses the chain rule to solve the gradient and update the weight. For complex composite functions, we divide them into a series of elementary functions such as addition, subtraction, multiplication and division or exponents, logarithms, trigonometric functions, and complete the derivation of composite functions through chain rules. For simplicity, this process is illustrated by an example of a common compound function in a neural network. Make the compound function 𝑓 (𝑥; 𝑤, 𝑏) as:

其中x是输入数据,w是权重,b是偏置。我们可以将该复合函数分解为:

并进行图形表示,如下所示:

[En]

And make a graphical representation, as follows:

整个复合函数 𝑓(𝑥; 𝑤, 𝑏) 关于参数 𝑤 和 𝑏 的导数可以通过 𝑓(𝑥; 𝑤, 𝑏) 与参数 𝑤 和 𝑏 之间路径上所有的导数连乘来得到,即:

以w为例,当 𝑥 = 1, 𝑤 = 0, 𝑏 = 0 时,可以得到:

注意:常用函数的导数:

BP算法使用链式规则来更新神经网络中每个节点的权值。让我们通过一个例子来介绍整个过程:

[En]

The back propagation algorithm uses the chain rule to update the weight of each node in the neural network. Let’s introduce the whole process through an example:

【举个栗子🌰:】

如下图是一个简单的神经网络用来举例:激活函数为sigmoid

前向传播运算

接下来是反向传播(求网络误差对各个权重参数的梯度):

我们先来求最简单的,求误差E对w5的导数。首先明确这是一个” 链式法则“的求导过程,要求误差E对w5的导数,需要先求误差E对out o1的导数,再求out o1对net o1的导数,最后再求net o1对w5的导数,经过这个链式法则,我们就可以求出误差E对w5的导数(偏导),如下图所示:

已经计算了导数(梯度),下面是反向传播和参数更新流程

[En]

The derivative (gradient) has been calculated, and here is the * back propagation and parameter update process * :

如果要想求误差E对w1的导数,误差E对w1的求导路径不止一条,这会稍微复杂一点,但换汤不换药,计算过程如下所示:

至此,“反向传播算法”的过程就讲完了啦!

Original: https://blog.csdn.net/weixin_46556352/article/details/124112434
Author: AI耽误的大厨
Title: 反向传播算法(BP算法)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/514272/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球