当前位置: 首页 > news >正文

深度学习笔记之循环神经网络(九)GRU的反向传播过程

引言

上一节介绍了门控循环单元 ( Gate Recurrent Unit,GRU ) (\text{Gate Recurrent Unit,GRU}) (Gate Recurrent Unit,GRU),本节我们参照 LSTM \text{LSTM} LSTM反向传播的格式,观察 GRU \text{GRU} GRU的反向传播过程。

回顾: GRU \text{GRU} GRU的前馈计算过程

GRU算法展开图
GRU \text{GRU} GRU前馈计算过程表示如下:
为了后续的反向传播过程,将过程分解的细致一些。其中 Z ~ ( t ) , r ~ ( t ) \widetilde{\mathcal Z}^{(t)},\widetilde{r}^{(t)} Z (t),r (t)分别表示更新门、重置门的线性计算过程。
{ Z ~ ( t ) = W H ⇒ Z ⋅ h ( t − 1 ) + W X ⇒ Z ⋅ x ( t ) + b Z Z ( t ) = σ ( Z ~ ( t ) ) r ~ ( t ) = W H ⇒ r ⋅ h ( t − 1 ) + W X ⇒ r ⋅ x ( t ) + b r r ( t ) = σ ( r ~ ( t ) ) h ~ ( t ) = Tanh [ W H ⇒ H ~ ⋅ ( r ( t ) ∗ h ( t − 1 ) ) + W X ⇒ H ~ ⋅ x ( t ) + b H ~ ] h ( t ) = ( 1 − Z ( t ) ) ∗ h ( t − 1 ) + Z ( t ) ∗ h ~ ( t ) \begin{cases} \begin{aligned} & \widetilde{\mathcal Z}^{(t)} = \mathcal W_{\mathcal H \Rightarrow \mathcal Z} \cdot h^{(t-1)} + \mathcal W_{\mathcal X \Rightarrow \mathcal Z} \cdot x^{(t)} + b_{\mathcal Z} \\ & \mathcal Z^{(t)} = \sigma(\widetilde{\mathcal Z}^{(t)}) \\ & \widetilde{r}^{(t)} = \mathcal W_{\mathcal H \Rightarrow r} \cdot h^{(t-1)} + \mathcal W_{\mathcal X \Rightarrow r} \cdot x^{(t)} + b_{r} \\ & r^{(t)} = \sigma(\widetilde{r}^{(t)}) \\ & \widetilde{h}^{(t)} = \text{Tanh} \left[\mathcal W_{\mathcal H \Rightarrow \widetilde{\mathcal H}} \cdot (r^{(t)} * h^{(t-1)}) + \mathcal W_{\mathcal X \Rightarrow \widetilde{\mathcal H}} \cdot x^{(t)} + b_{\widetilde{\mathcal H}}\right] \\ & h^{(t)} = (1 -\mathcal Z^{(t)}) * h^{(t-1)} + \mathcal Z^{(t)} * \widetilde{h}^{(t)} \end{aligned} \end{cases} Z (t)=WHZh(t1)+WXZx(t)+bZZ(t)=σ(Z (t))r (t)=WHrh(t1)+WXrx(t)+brr(t)=σ(r (t))h (t)=Tanh[WHH (r(t)h(t1))+WXH x(t)+bH ]h(t)=(1Z(t))h(t1)+Z(t)h (t)

场景设计

上述仅描述的是 GRU \text{GRU} GRU关于序列信息 h ( t ) ( t = 1 , 2 , ⋯ , T ) h^{(t)}(t=1,2,\cdots,\mathcal T) h(t)(t=1,2,,T)的迭代过程。各时刻的输出特征以及损失函数于循环神经网络相同:

  • 使用 Softmax \text{Softmax} Softmax激活函数,其输出结果作为模型对 t t t时刻的预测结果
    { C ( t ) = W H ⇒ C ⋅ h ( t ) + b h y ^ ( t ) = Softmax ( C ( t ) ) \begin{cases} \mathcal C^{(t)} = \mathcal W_{\mathcal H \Rightarrow \mathcal C} \cdot h^{(t)} + b_{h} \\ \hat y^{(t)} = \text{Softmax}(\mathcal C^{(t)}) \end{cases} {C(t)=WHCh(t)+bhy^(t)=Softmax(C(t))
  • 关于 t t t时刻预测结果 y ^ ( t ) \hat y^{(t)} y^(t)与真实分布 y ( t ) y^{(t)} y(t)之间的偏差信息使用交叉熵 ( CrossEntropy ) (\text{CrossEntropy}) (CrossEntropy)进行表示:
    其中 n Y n_{\mathcal Y} nY表示预测/真实分布的维数。
    L ( t ) = L [ y ^ ( t ) , y ( t ) ] = − ∑ j = 1 n Y y j ( t ) log ⁡ [ y ^ j ( t ) ] \mathcal L^{(t)} = \mathcal L \left[\hat y^{(t)},y^{(t)}\right] = - \sum_{j=1}^{n_\mathcal Y} y_j^{(t)} \log \left[\hat y_j^{(t)}\right] L(t)=L[y^(t),y(t)]=j=1nYyj(t)log[y^j(t)]
  • 所有时刻交叉熵结果的累加和构成完整的损失函数 L \mathcal L L
    L = ∑ t = 1 T L ( t ) = ∑ t = 1 T L [ y ^ ( t ) , y ( t ) ] \begin{aligned} \mathcal L & = \sum_{t=1}^{\mathcal T} \mathcal L^{(t)}\\ & = \sum_{t=1}^{\mathcal T} \mathcal L \left[\hat y^{(t)},y^{(t)}\right] \end{aligned} L=t=1TL(t)=t=1TL[y^(t),y(t)]

反向传播过程

T \mathcal T T时刻的反向传播过程

T \mathcal T T时刻重置门 ∂ L ∂ W h ( T ) ⇒ Z ( T ) \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal W_{\mathcal h^{(\mathcal T)} \Rightarrow \mathcal Z^{(\mathcal T)}}}\end{aligned} Wh(T)Z(T)L的反向传播为例:

  • 计算梯度 ∂ L ∂ L ( T ) \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal L^{(\mathcal T)}}\end{aligned} L(T)L
    其中仅有 L ( T ) \mathcal L^{(\mathcal T)} L(T)一项存在梯度,其余项均视作常数。
    ∂ L ∂ L ( T ) = ∂ ∂ L ( T ) [ ∑ t = 1 T L ( t ) ] = 0 + 0 + ⋯ + 1 = 1 \frac{\partial \mathcal L}{\partial \mathcal L^{(\mathcal T)}} = \frac{\partial}{\partial \mathcal L^{(\mathcal T)}} \left[\sum_{t=1}^{\mathcal T} \mathcal L^{(t)}\right] = 0 + 0 + \cdots + 1 = 1 L(T)L=L(T)[t=1TL(t)]=0+0++1=1
  • 计算梯度 ∂ L ( T ) ∂ C ( T ) \begin{aligned}\frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal C^{(\mathcal T)}}\end{aligned} C(T)L(T)
    关于 Softmax \text{Softmax} Softmax激活函数与交叉熵组合的梯度描述,见循环神经网络—— Softmax \text{Softmax} Softmax函数的反向传播过程一节,这里不再赘述。
    { L ( T ) = − ∑ j = 1 n Y y j ( T ) log ⁡ [ y ^ j ( T ) ] y ^ ( T ) = Softmax [ C ( T ) ] ⇒ ∂ L ( T ) ∂ C ( T ) = y ^ ( T ) − y ( T ) \begin{aligned} & \begin{cases} \mathcal L^{(\mathcal T)} = -\sum_{j=1}^{n_{\mathcal Y}}y_j^{(\mathcal T)} \log \left[\hat y_j^{(\mathcal T)}\right] \\ \hat y^{(\mathcal T)} = \text{Softmax}[\mathcal C^{(\mathcal T)}] \end{cases} \\ & \Rightarrow \frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal C^{(\mathcal T)}} = \hat y^{(\mathcal T)} - y^{(\mathcal T)} \end{aligned} {L(T)=j=1nYyj(T)log[y^j(T)]y^(T)=Softmax[C(T)]C(T)L(T)=y^(T)y(T)
  • 继续计算梯度 ∂ C ( T ) ∂ h ( T ) \begin{aligned}\frac{\partial \mathcal C^{(\mathcal T)}}{\partial h^{(\mathcal T)}}\end{aligned} h(T)C(T)
    ∂ C ( T ) ∂ h ( T ) = ∂ ∂ h ( T ) [ W H ⇒ C ⋅ h ( T ) + b h ] = W H ⇒ C \frac{\partial \mathcal C^{(\mathcal T)}}{\partial h^{(\mathcal T)}} = \frac{\partial}{\partial h^{(\mathcal T)}} \left[\mathcal W_{\mathcal H \Rightarrow \mathcal C} \cdot h^{(\mathcal T)} + b_{h}\right] = \mathcal W_{\mathcal H \Rightarrow \mathcal C} h(T)C(T)=h(T)[WHCh(T)+bh]=WHC

至此,关于梯度 ∂ L ∂ h ( T ) \begin{aligned}\frac{\partial \mathcal L}{\partial h^{(\mathcal T)}}\end{aligned} h(T)L可表示为:
∂ L ∂ h ( T ) = ∂ L ∂ L ( T ) ⋅ ∂ L ( T ) ∂ C ( T ) ⋅ ∂ C ( T ) ∂ h ( T ) = 1 ⋅ [ W H ⇒ C ] T ⋅ ( y ^ ( T ) − y ( T ) ) \begin{aligned} \frac{\partial \mathcal L}{\partial h^{(\mathcal T)}} & = \frac{\partial \mathcal L}{\partial \mathcal L^{(\mathcal T)}} \cdot \frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal C^{(\mathcal T)}} \cdot \frac{\partial \mathcal C^{(\mathcal T)}}{\partial h^{(\mathcal T)}} \\ & = 1 \cdot \left[\mathcal W_{\mathcal H \Rightarrow \mathcal C}\right]^T \cdot (\hat y^{(\mathcal T)} - y^{(\mathcal T)}) \end{aligned} h(T)L=L(T)LC(T)L(T)h(T)C(T)=1[WHC]T(y^(T)y(T))
观察:从 h ( T ) h^{(\mathcal T)} h(T)开始,从 h ( T ) ⇒ W h ( T ) ⇒ Z ( T ) h^{(\mathcal T)} \Rightarrow \mathcal W_{h^{(\mathcal T)} \Rightarrow \mathcal Z^{(\mathcal T)}} h(T)Wh(T)Z(T)传播路径都有哪些。
只有唯一一条,其前馈计算路径表示为:
{ h ( t ) = ( 1 − Z ( t ) ) ∗ h ( t − 1 ) + Z ( t ) ∗ h ~ ( t ) Z ( t ) = σ ( Z ~ ( t ) ) Z ~ ( t ) = W H ⇒ Z ⋅ h ( t − 1 ) + W X ⇒ Z ⋅ x ( t ) + b Z \begin{cases} \begin{aligned} & h^{(t)} = (1 -\mathcal Z^{(t)}) * h^{(t-1)} + \mathcal Z^{(t)} * \widetilde{h}^{(t)} \\ & \mathcal Z^{(t)} = \sigma(\widetilde{\mathcal Z}^{(t)}) \\ & \widetilde{\mathcal Z}^{(t)} = \mathcal W_{\mathcal H \Rightarrow \mathcal Z} \cdot h^{(t-1)} + \mathcal W_{\mathcal X \Rightarrow \mathcal Z} \cdot x^{(t)} + b_{\mathcal Z} \end{aligned} \end{cases} h(t)=(1Z(t))h(t1)+Z(t)h (t)Z(t)=σ(Z (t))Z (t)=WHZh(t1)+WXZx(t)+bZ
对应反向传播结果表示为:
∂ h ( T ) ∂ W h ( T ) ⇒ Z ( T ) = ∂ h ( T ) ∂ Z ( T ) ⋅ ∂ Z ( T ) ∂ Z ~ ( T ) ⋅ ∂ Z ~ ( T ) ∂ W h ( T ) ⇒ Z ( T ) = [ h ~ ( T ) − h ( T − 1 ) ] ⋅ [ Sigmoid ( Z ~ ( T ) ) ] ′ ⋅ h ( T − 1 ) \begin{aligned} \frac{\partial h^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T)} \Rightarrow \mathcal Z^{(\mathcal T)}}} & = \frac{\partial h^{(\mathcal T)}}{\partial \mathcal Z^{(\mathcal T)}} \cdot \frac{\partial \mathcal Z^{(\mathcal T)}}{\partial \widetilde{\mathcal Z}^{(\mathcal T)}} \cdot \frac{\partial \widetilde{\mathcal Z}^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T)} \Rightarrow \mathcal Z^{(\mathcal T)}}} \\ & = \left[\widetilde{h}^{(\mathcal T)} - h^{(\mathcal T - 1)}\right] \cdot \left[\text{Sigmoid}(\widetilde{\mathcal Z}^{(\mathcal T)})\right]' \cdot h^{(\mathcal T - 1)} \end{aligned} Wh(T)Z(T)h(T)=Z(T)h(T)Z (T)Z(T)Wh(T)Z(T)Z (T)=[h (T)h(T1)][Sigmoid(Z (T))]h(T1)
最终,关于 ∂ L ∂ W h ( T ) ⇒ Z ( T ) \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal W_{\mathcal h^{(\mathcal T)} \Rightarrow \mathcal Z^{(\mathcal T)}}}\end{aligned} Wh(T)Z(T)L反向传播结果为:
这里更主要的是描述它的反向传播路径,它的具体展开在后续不再赘述。
∂ L ∂ W h ( T ) ⇒ Z ( T ) = ∂ L ∂ h ( T ) ⋅ ∂ h ( T ) ∂ W h ( T ) ⇒ Z ( T ) = { [ W H ⇒ C ] T ⋅ ( y ^ ( T ) − y ( T ) ) } ⋅ { [ h ~ ( T ) − h ( T − 1 ) ] ⋅ [ Sigmoid ( Z ~ ( T ) ) ] ′ ⋅ h ( T − 1 ) } \begin{aligned} \begin{aligned}\frac{\partial \mathcal L}{\partial \mathcal W_{\mathcal h^{(\mathcal T)} \Rightarrow \mathcal Z^{(\mathcal T)}}}\end{aligned} & = \frac{\partial \mathcal L}{\partial h^{(\mathcal T)}} \cdot \frac{\partial h^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T)}\Rightarrow \mathcal Z^{(\mathcal T)}}} \\ & = \left\{\left[\mathcal W_{\mathcal H \Rightarrow \mathcal C}\right]^T \cdot (\hat y^{(\mathcal T)} - y^{(\mathcal T)})\right\} \cdot \left\{ \left[\widetilde{h}^{(\mathcal T)} - h^{(\mathcal T - 1)}\right] \cdot \left[\text{Sigmoid}(\widetilde{\mathcal Z}^{(\mathcal T)})\right]' \cdot h^{(\mathcal T - 1)}\right\} \end{aligned} Wh(T)Z(T)L=h(T)LWh(T)Z(T)h(T)={[WHC]T(y^(T)y(T))}{[h (T)h(T1)][Sigmoid(Z (T))]h(T1)}

T − 1 \mathcal T - 1 T1时刻的反向传播路径

关于 T − 1 \mathcal T - 1 T1时刻的重置门梯度 ∂ L ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{aligned} \frac{\partial \mathcal L}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \end{aligned} Wh(T1)Z(T1)L,它的路径主要包含两大类

第一类路径:同 T \mathcal T T时刻路径,从对应的 L ( T − 1 ) \mathcal L^{(\mathcal T - 1)} L(T1)直接传至 W h ( T − 1 ) ⇒ Z ( T − 1 ) \mathcal W_{h^{(\mathcal T - 1)}\Rightarrow \mathcal Z^{(\mathcal T - 1)}} Wh(T1)Z(T1)
该路径与上述 T \mathcal T T时刻的路径类型相同,将对应的上标 T \mathcal T T改为 T − 1 \mathcal T - 1 T1即可。
∂ L ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) = ∂ L ( T − 1 ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{aligned} \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} & = \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \end{aligned} Wh(T1)Z(T1)L(T1)=h(T1)L(T1)Wh(T1)Z(T1)h(T1)
第二类路径:重新观察 W h ( T − 1 ) ⇒ Z ( T − 1 ) \mathcal W_{h^{(\mathcal T - 1)}\Rightarrow \mathcal Z^{(\mathcal T - 1)}} Wh(T1)Z(T1)只会出现在 Z ( T − 1 ) \mathcal Z^{(\mathcal T - 1)} Z(T1)中,并且 Z ( T − 1 ) \mathcal Z^{(\mathcal T - 1)} Z(T1)只会出现在 h ( T − 1 ) h^{(\mathcal T - 1)} h(T1)中。因此:仅需要找出与 h ( T − 1 ) h^{(\mathcal T - 1)} h(T1)相关的所有路径即可,最终都可以使用 ∂ h ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{aligned}\frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}}\end{aligned} Wh(T1)Z(T1)h(T1)将梯度传递给 W h ( T − 1 ) ⇒ Z ( T − 1 ) \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}} Wh(T1)Z(T1)
其中‘第一类路径’就是其中一种情况。只不过它是从当前 T − 1 \mathcal T - 1 T1时刻直接传递得到的梯度结果。而第二类路径我们关注从 T \mathcal T T时刻传递产生的梯度信息。
T ⇒ T − 1 \mathcal T \Rightarrow \mathcal T - 1 TT1时刻中,关于 h ( T − 1 ) h^{(\mathcal T - 1)} h(T1)的梯度路径一共包含 4 4 4条:

  • 第一条:通过 T \mathcal T T时刻 h ( T ) h^{(\mathcal T)} h(T)中的 h ( T − 1 ) h^{(\mathcal T - 1)} h(T1)进行传递。
    { Forword :  h ( T ) = ( 1 − Z ( T ) ) ∗ h ( T − 1 ) + Z ( T ) ∗ h ~ ( T ) Backward :  ∂ L ( T ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) ⇒ ∂ L ( T ) ∂ h ( T ) ⋅ ∂ h ( T ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{cases} \text{Forword : } h^{(\mathcal T)} = (1 -\mathcal Z^{(\mathcal T)}) * h^{(\mathcal T -1)} + \mathcal Z^{(\mathcal T)} * \widetilde{h}^{(\mathcal T)} \\ \quad \\ \text{Backward : }\begin{aligned} \frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \Rightarrow \frac{\partial \mathcal L^{(\mathcal T)}}{\partial h^{(\mathcal T)}} \cdot \frac{\partial h^{(\mathcal T)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \end{aligned} \end{cases} Forword : h(T)=(1Z(T))h(T1)+Z(T)h (T)Backward : Wh(T1)Z(T1)L(T)h(T)L(T)h(T1)h(T)Wh(T1)Z(T1)h(T1)
  • 第二条:通过 T \mathcal T T时刻 h ( T ) h^{(\mathcal T)} h(T)中的 Z ( T ) \mathcal Z^{(\mathcal T)} Z(T) h ( T − 1 ) h^{(\mathcal T-1)} h(T1)进行传递。
    { Forward :  { h ( T ) = ( 1 − Z ( T ) ) ∗ h ( T − 1 ) + Z ( T ) ∗ h ~ ( T ) Z ( T ) = σ [ W H ⇒ Z ⋅ h ( T − 1 ) + W X ⇒ Z ⋅ x ( T ) + b Z ] Backward :  ∂ L ( T ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) ⇒ ∂ L ( T ) ∂ h ( T ) ⋅ ∂ h ( T ) ∂ Z ( T ) ⋅ ∂ Z ( T ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{cases} \text{Forward : } \begin{cases} h^{(\mathcal T)} = (1 -\mathcal Z^{(\mathcal T)}) * h^{(\mathcal T -1)} + \mathcal Z^{(\mathcal T)} * \widetilde{h}^{(\mathcal T)} \\ \mathcal Z^{(\mathcal T)} = \sigma \left[\mathcal W_{\mathcal H \Rightarrow \mathcal Z} \cdot h^{(\mathcal T -1)} + \mathcal W_{\mathcal X \Rightarrow \mathcal Z} \cdot x^{(\mathcal T)} + b_{\mathcal Z}\right] \end{cases} \quad \\ \text{Backward : } \begin{aligned} \frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \Rightarrow \frac{\partial \mathcal L^{(\mathcal T)}}{\partial h^{(\mathcal T)}} \cdot \frac{\partial h^{(\mathcal T)}}{\partial \mathcal Z^{(\mathcal T)}} \cdot \frac{\partial \mathcal Z^{(\mathcal T)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \end{aligned} \end{cases} Forward : {h(T)=(1Z(T))h(T1)+Z(T)h (T)Z(T)=σ[WHZh(T1)+WXZx(T)+bZ]Backward : Wh(T1)Z(T1)L(T)h(T)L(T)Z(T)h(T)h(T1)Z(T)Wh(T1)Z(T1)h(T1)
  • 第三条:通过 T \mathcal T T时刻 h ( T ) h^{(\mathcal T)} h(T)中的 h ~ ( T ) \widetilde{h}^{(\mathcal T)} h (T) h ( T − 1 ) h^{(\mathcal T - 1)} h(T1)进行传递。
    { Forward :  { h ( T ) = ( 1 − Z ( T ) ) ∗ h ( T − 1 ) + Z ( T ) ∗ h ~ ( T ) h ~ ( T ) = Tanh [ W H ⇒ H ~ ⋅ ( r ( T ) ∗ h ( T − 1 ) ) + W X ⇒ H ~ ⋅ x ( T ) + b H ~ ] Backward :  ∂ L ( T ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) ⇒ ∂ L ( T ) ∂ h ( T ) ⋅ ∂ h ( T ) ∂ h ~ ( T ) ⋅ h ~ ( T ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{cases} \text{Forward : } \begin{cases} h^{(\mathcal T)} = (1 -\mathcal Z^{(\mathcal T)}) * h^{(\mathcal T -1)} + \mathcal Z^{(\mathcal T)} * \widetilde{h}^{(\mathcal T)} \\ \widetilde{h}^{(\mathcal T)} = \text{Tanh} \left[\mathcal W_{\mathcal H \Rightarrow \widetilde{\mathcal H}} \cdot (r^{(\mathcal T)} * h^{(\mathcal T -1)}) + \mathcal W_{\mathcal X \Rightarrow \widetilde{\mathcal H}} \cdot x^{(\mathcal T)} + b_{\widetilde{\mathcal H}}\right] \end{cases}\\ \quad \\ \text{Backward : } \begin{aligned} \frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \Rightarrow \frac{\partial \mathcal L^{(\mathcal T)}}{\partial h^{(\mathcal T)}} \cdot \frac{\partial h^{(\mathcal T)}}{\partial \widetilde{h}^{(\mathcal T)}} \cdot \frac{\widetilde{h}^{(\mathcal T)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \end{aligned} \end{cases} Forward : {h(T)=(1Z(T))h(T1)+Z(T)h (T)h (T)=Tanh[WHH (r(T)h(T1))+WXH x(T)+bH ]Backward : Wh(T1)Z(T1)L(T)h(T)L(T)h (T)h(T)h(T1)h (T)Wh(T1)Z(T1)h(T1)
  • 第四条:第三条路径类似,只不过从 h ~ ( T ) \widetilde{h}^{(\mathcal T)} h (T)中的 r ( T ) r^{(\mathcal T)} r(T) h ( T − 1 ) h^{(\mathcal T - 1)} h(T1)进行传递。
    { Forward :  { h ( T ) = ( 1 − Z ( T ) ) ∗ h ( T − 1 ) + Z ( T ) ∗ h ~ ( T ) h ~ ( T ) = Tanh [ W H ⇒ H ~ ⋅ ( r ( T ) ∗ h ( T − 1 ) ) + W X ⇒ H ~ ⋅ x ( T ) + b H ~ ] r ~ ( T ) = W H ⇒ r ⋅ h ( T − 1 ) + W X ⇒ r ⋅ x ( T ) + b r Backward :  ∂ L ( T ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) ⇒ ∂ L ( T ) ∂ h ( T ) ⋅ ∂ h ( T ) ∂ h ~ ( T ) ⋅ ∂ h ~ ( T ) ∂ r ( T ) ⋅ ∂ r ( T ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ W h ( T − 1 ) ⇒ Z ( T − 1 ) \begin{cases} \text{Forward : } \begin{cases} h^{(\mathcal T)} = (1 -\mathcal Z^{(\mathcal T)}) * h^{(\mathcal T -1)} + \mathcal Z^{(\mathcal T)} * \widetilde{h}^{(\mathcal T)} \\ \widetilde{h}^{(\mathcal T)} = \text{Tanh} \left[\mathcal W_{\mathcal H \Rightarrow \widetilde{\mathcal H}} \cdot (r^{(\mathcal T)} * h^{(\mathcal T -1)}) + \mathcal W_{\mathcal X \Rightarrow \widetilde{\mathcal H}} \cdot x^{(\mathcal T)} + b_{\widetilde{\mathcal H}}\right] \\ \widetilde{r}^{(\mathcal T)} = \mathcal W_{\mathcal H \Rightarrow r} \cdot h^{(\mathcal T -1)} + \mathcal W_{\mathcal X \Rightarrow r} \cdot x^{(\mathcal T)} + b_{r} \end{cases}\\ \quad \\ \text{Backward : } \begin{aligned} \frac{\partial \mathcal L^{(\mathcal T)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \Rightarrow \frac{\partial \mathcal L^{(\mathcal T)}}{\partial h^{(\mathcal T)}} \cdot \frac{\partial h^{(\mathcal T)}}{\partial \widetilde{h}^{(\mathcal T)}} \cdot \frac{\partial \widetilde{h}^{(\mathcal T)}}{\partial r^{(\mathcal T)}} \cdot \frac{\partial r^{(\mathcal T)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 1)} \Rightarrow \mathcal Z^{(\mathcal T - 1)}}} \end{aligned} \end{cases} Forward :  h(T)=(1Z(T))h(T1)+Z(T)h (T)h (T)=Tanh[WHH (r(T)h(T1))+WXH x(T)+bH ]r (T)=WHrh(T1)+WXrx(T)+brBackward : Wh(T1)Z(T1)L(T)h(T)L(T)h (T)h(T)r(T)h (T)h(T1)r(T)Wh(T1)Z(T1)h(T1)

至此, T ⇒ T − 1 \mathcal T \Rightarrow \mathcal T - 1 TT1时刻的 5 5 5条路径已全部找全。其中:

  • 1 1 1条是 T − 1 \mathcal T - 1 T1时刻自身路径;
  • 剩余 4 4 4条均是 T ⇒ T − 1 \mathcal T \Rightarrow \mathcal T - 1 TT1的传播路径。

T − 2 \mathcal T - 2 T2时刻的反向传播路径

再往下走一步,观察它路径传播数量规律

  • 1 1 1条依然是 L ( T − 2 ) \mathcal L^{(\mathcal T - 2)} L(T2) W h ( T − 2 ) ⇒ Z ( T − 2 ) \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}} Wh(T2)Z(T2)直接传递的梯度:
    ∂ L ( T − 2 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) = ∂ L ( T − 2 ) ∂ h ( T − 2 ) ⋅ ∂ h ( T − 2 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) \begin{aligned} \frac{\partial \mathcal L^{(\mathcal T - 2)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}} = \frac{\partial \mathcal L^{(\mathcal T - 2)}}{\partial h^{(\mathcal T - 2)}} \cdot \frac{\partial h^{(\mathcal T - 2)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}} \end{aligned} Wh(T2)Z(T2)L(T2)=h(T2)L(T2)Wh(T2)Z(T2)h(T2)
  • 存在 4 4 4是从 L ( T − 1 ) \mathcal L^{(\mathcal T - 1)} L(T1)开始,从 T − 1 ⇒ T − 2 \mathcal T - 1 \Rightarrow \mathcal T - 2 T1T2时刻传递的路径:
    ∂ L ( T − 1 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) = { ∂ L ( T − 1 ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ h ( T − 2 ) ⋅ ∂ h ( T − 2 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) ∂ L ( T − 1 ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ Z ( T − 1 ) ⋅ ∂ Z ( T − 1 ) ∂ h ( T − 2 ) ⋅ ∂ h ( T − 2 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) ∂ L ( T − 1 ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ h ~ ( T − 1 ) ⋅ ∂ h ~ ( T − 1 ) ∂ h ( T − 2 ) ⋅ ∂ h ( T − 2 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) ∂ L ( T − 1 ) ∂ h ( T − 1 ) ⋅ ∂ h ( T − 1 ) ∂ h ~ ( T − 1 ) ⋅ ∂ h ~ ( T − 1 ) ∂ r ( T − 1 ) ⋅ ∂ r ( T − 1 ) ∂ h ( T − 2 ) ⋅ ∂ h ( T − 2 ) ∂ W h ( T − 2 ) ⇒ Z ( T − 2 ) \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}} = \begin{cases} \begin{aligned} & \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 2)}} \cdot \frac{\partial h^{(\mathcal T - 2)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}} \\ & \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \mathcal Z^{(\mathcal T - 1)}} \cdot \frac{\partial \mathcal Z^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 2)}} \cdot \frac{\partial h^{(\mathcal T - 2)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}}\\ & \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \widetilde{h}^{(\mathcal T - 1)}} \cdot \frac{\partial \widetilde{h}^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 2)}} \cdot \frac{\partial h^{(\mathcal T - 2)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}} \\ & \frac{\partial \mathcal L^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 1)}} \cdot \frac{\partial h^{(\mathcal T - 1)}}{\partial \widetilde{h}^{(\mathcal T - 1)}} \cdot \frac{\partial \widetilde{h}^{(\mathcal T - 1)}}{\partial r^{(\mathcal T - 1)}} \cdot \frac{\partial r^{(\mathcal T - 1)}}{\partial h^{(\mathcal T - 2)}} \cdot \frac{\partial h^{(\mathcal T - 2)}}{\partial \mathcal W_{h^{(\mathcal T - 2)} \Rightarrow \mathcal Z^{(\mathcal T - 2)}}} \end{aligned} \end{cases} Wh(T2)Z(T2)L(T1)= h(T1)L(T1)h(T2)h(T1)Wh(T2)Z(T2)h(T2)h(T1)L(T1)Z(T1)h(T1)h(T2)Z(T1)Wh(T2)Z(T2)h(T2)h(T1)L(T1)h (T1)h(T1)h(T2)h (T1)Wh(T2)Z(T2)h(T2)h(T1)L(T1)h (T1)h(T1)r(T1)h (T1)h(T2)r(T1)Wh(T2)Z(T2)h(T2)
  • 存在 4 × 4 4 \times 4 4×4是从 L ( T ) \mathcal L^{(\mathcal T)} L(T)开始,从 T ⇒ T − 2 \mathcal T \Rightarrow \mathcal T- 2 TT2时刻传递的路径。
    这个就不写了,太墨迹了。

这仅仅是 T ⇒ T − 2 \mathcal T \Rightarrow \mathcal T - 2 TT2时刻的路径数量, T − 3 \mathcal T - 3 T3时刻关于 L ( T ) \mathcal L^{(\mathcal T)} L(T)相关的梯度路径有 4 × 4 × 4 = 64 4 \times 4 \times 4 = 64 4×4×4=64条,以此类推。

总结

LSTM \text{LSTM} LSTM的反向传播路径相比, LSTM \text{LSTM} LSTM仅仅从 T ⇒ T − 2 \mathcal T \Rightarrow \mathcal T - 2 TT2时刻传递的路径就有 24 24 24,而 GRU \text{GRU} GRU仅有 16 16 16条,相比之下,极大地减小了反向传播路径的数量;
降低了时间、空间复杂度;

其次, GRU \text{GRU} GRU相比 LSTM \text{LSTM} LSTM减少了模型参数的更新数量,降低了过拟合 ( OverFitting ) (\text{OverFitting}) (OverFitting)的风险。

它的抑制梯度消失原理与 LSTM \text{LSTM} LSTM思想相同。首先随着反向传播深度的加深,相关梯度路径依然会呈指数级别增长,但规模明显小于 LSTM \text{LSTM} LSTM;并且其梯度计算过程依然有更新门、重置门自身参与梯度运算,从而调节各梯度分量的配置情况

相关参考:
GRU循环神经网络 —— LSTM的轻量级版本

相关文章:

深度学习笔记之循环神经网络(九)GRU的反向传播过程

深度学习笔记之循环神经网络——GRU的反向传播过程 引言回顾: GRU \text{GRU} GRU的前馈计算过程场景设计 反向传播过程 T \mathcal T T时刻的反向传播过程 T − 1 \mathcal T - 1 T−1时刻的反向传播路径 T − 2 \mathcal T - 2 T−2时刻的反向传播路径 总结 引言 …...

ISFP型人格的性格缺陷和心理问题分析

ISFP人格的特征:性格敏感、为人善良、是具有有创造力的人格类型。他们喜欢追求内心的感受和情感,注重自由、个性和独立。ISFP性人格偏于内向,善于自省,对情绪敏感度高,同理心强。 每种人格类型的都有各自的优势和不足…...

HTML <dir> 标签

HTML5 中不支持 <dir> 标签在 HTML 4 中用于列出目录标题。 实例 目录列表&#xff1a; <dir><li>HTML</li><li>XHTML</li><li>CSS</li> </dir>浏览器支持 IEFirefoxChromeSafariOpera 所有主流浏览器都支持 <…...

leetcode 621. 任务调度器

题目链接&#xff1a;leetcode 621 1.题目 给你一个用字符数组 tasks 表示的 CPU 需要执行的任务列表。其中每个字母表示一种不同种类的任务。任务可以以任意顺序执行&#xff0c;并且每个任务都可以在 1 个单位时间内执行完。在任何一个单位时间&#xff0c;CPU 可以完成一个…...

线程任务的取消

如果外部代码能在某个操作正常完成之前将其置入“完成”状态&#xff0c;那么这个操作就可以称为可取消的(Cancellable)。取消某个操作的原因很多&#xff1a; 用户请求取消。用户点击图形界面程序中的“取消”按钮&#xff0c;或者通过管理接口来发出取消请求,例如JMX (Java …...

在线聊天项目

人事管理项目-在线聊天 后端接口实现前端实现 在线聊天是一个为了方便HR进行快速沟通提高工作效率而开发的功能&#xff0c;考虑到一个公司中的HR并不多&#xff0c;并发量不大&#xff0c;因此这里直接使用最基本的WebSocket来完成该功能。 后端接口实现 要使用WebSocket&…...

动态规划-硬币排成线

动态规划-硬币排成线 1 描述2 样例2.1 样例 1:2.2 样例 2:2.3 样例 3: 3 算法解题思路及实现3.1 算法解题分析3.1.1 确定状态3.1.2 转移方程3.1.3 初始条件和边界情况3.1.4 计算顺序 3.2 算法实现3.2.1 动态规划常规实现3.2.2 动态规划滚动数组 该题是lintcode的第394题&#x…...

有效的括号——力扣20

题目描述 思路 1.判断括号的有效性可以使用「栈」这一数据结构来解决 2.遍历给定的字符串 s。当遇到一个左括号时&#xff0c;我们会期望在后续的遍历中&#xff0c;有一个相同类型的右括号将其闭合。由于后遇到的左括号要先闭合&#xff0c;因此我们可以将这个左括号放入栈顶。…...

【轻量级网络】华为诺亚:VanillaNet

文章目录 0. 前言1. 网络结构2. VanillaNet非线性表达能力增强策略2.1 深度训练2.2 扩展激活函数 3. 总结4. 参考 0. 前言 随着人工智能芯片的发展&#xff0c;神经网络推理速度的瓶颈不再是FLOPs或参数量&#xff0c;因为现代GPU可以很容易地进行计算能力较强的并行计算。相比…...

读写ini配置文件(C++)

文章目录 1、为什么要使用ini或者其它(例如xml,json)配置文件&#xff1f;2、ini文件基本介绍3、ini配置文件的格式4、C读写ini配置文件5、 代码示例6、 配置文件的解析库 文章转载于&#xff1a;https://blog.csdn.net/weixin_44517656/article/details/109014236 1、为什么要…...

Python对接亚马逊电商平台SP-API的一些概念理解准备

❝ 除了第三方服务商&#xff0c;其实亚马逊卖家本身也可以通过和SP-API的对接&#xff0c;利用程序来自动化亚马逊店铺销售运营管理中很多环节的工作&#xff0c;简单的应用比如可以利用SP-API的对接&#xff0c;实现亚马逊卖家后台各类报表的定期自动下载以及数据分析整理工…...

[Halcon3D] 主流的3D光学视觉方案及原理

&#x1f4e2;博客主页&#xff1a;https://loewen.blog.csdn.net&#x1f4e2;欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1f4dd; 如有错误敬请指正&#xff01;&#x1f4e2;本文由 丶布布原创&#xff0c;首发于 CSDN&#xff0c;转载注明出处&#x1f649;&#x1f4e2;现…...

Go Web下gin框架使用(二)

〇、gin 路由 Gin是一个用于构建Web应用程序的Go语言框架&#xff0c;它具有简单、快速、灵活的特点。在Gin中&#xff0c;可以使用路由来定义URL和处理程序之间的映射关系。 r : gin.Default()// 访问 /index 这个路由// 获取信息r.GET("/index", func(c *gin.Con…...

算法笔记-线段树合并

线段树合并 前置知识&#xff1a;权值线段树、动态开点 将两棵线段树的信息合并成一棵线段树。 可以新建一颗线段树保存原来两颗线段树的信息&#xff0c;也可以将第二棵线段树维护的信息加到第一棵线段树上。 前者的空间复杂度较高&#xff0c;如果合并之前的线段树不会再用…...

Fiddler抓取IOS数据包实践教程

Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的“进出”Fiddler的数据(指cookie,html,js,css等文件)。 本章教程,主要介绍如何利用Fiddler抓取IOS数据包相关教程。 目录 一、打开Fiddler监听端口 二、配置网…...

Ansible基础4——变量、机密、事实

文章目录 一、变量二、机密2.1 创建加密文件2.2 查看加密文件2.3 编辑加密文件内容2.4 加密现有文件2.5 解密文件2.6 更改加密密码 三、事实3.1 收集展示事实3.2 展示某个结果3.3 新旧事实命令3.4 关闭事实3.5 魔法变量 一、变量 常设置的变量&#xff1a; 要创建的用户要安装的…...

React实现Vue的watch监听属性

在 Vue 中可以简单地使用 watch 来监听数据的变化&#xff0c;还能获取到改变前的旧值&#xff0c;而在 React 中是没有 watch 的。 React中比较复杂&#xff0c;但是我们如果想在 React 中实现一个类似 Vue 的 watch 监听属性&#xff0c;也不是没有办法。 在React类组件中实…...

axios、跨域与JSONP、防抖和节流

文章目录 一、axios1、什么是axios2、axios发起GET请求3、axios发起POST请求4、直接使用axios发起请求 二、跨域与JSONP1、了解同源策略和跨域2、JSONP&#xff08;1&#xff09;实现一个简单的JSONP&#xff08;2&#xff09;JSONP的缺点&#xff08;3&#xff09;jQuery中的J…...

macOS Ventura 13.5beta2 (22G5038d)发布

系统介绍 黑果魏叔 6 月 1 日消息&#xff0c;苹果今日向 Mac 电脑用户推送了 macOS 13.5 开发者预览版 Beta 2 更新&#xff08;内部版本号&#xff1a;22G5038d&#xff09;&#xff0c;本次更新距离上次发布隔了 12 天。 macOS Ventura 带来了台前调度、连续互通相机、Fac…...

jwt----介绍,原理

token&#xff1a;服务的生成的加密字符串&#xff0c;如果存在客户端浏览器上&#xff0c;就叫cookie -三部分&#xff1a;头&#xff0c;荷载&#xff0c;签名 -签发&#xff1a;登录成功&#xff0c;签发 -认证&#xff1a;认证类中认证 # jwt&…...

【网络】每天掌握一个Linux命令 - iftop

在Linux系统中&#xff0c;iftop是网络管理的得力助手&#xff0c;能实时监控网络流量、连接情况等&#xff0c;帮助排查网络异常。接下来从多方面详细介绍它。 目录 【网络】每天掌握一个Linux命令 - iftop工具概述安装方式核心功能基础用法进阶操作实战案例面试题场景生产场景…...

Qt/C++开发监控GB28181系统/取流协议/同时支持udp/tcp被动/tcp主动

一、前言说明 在2011版本的gb28181协议中&#xff0c;拉取视频流只要求udp方式&#xff0c;从2016开始要求新增支持tcp被动和tcp主动两种方式&#xff0c;udp理论上会丢包的&#xff0c;所以实际使用过程可能会出现画面花屏的情况&#xff0c;而tcp肯定不丢包&#xff0c;起码…...

Xshell远程连接Kali(默认 | 私钥)Note版

前言:xshell远程连接&#xff0c;私钥连接和常规默认连接 任务一 开启ssh服务 service ssh status //查看ssh服务状态 service ssh start //开启ssh服务 update-rc.d ssh enable //开启自启动ssh服务 任务二 修改配置文件 vi /etc/ssh/ssh_config //第一…...

SCAU期末笔记 - 数据分析与数据挖掘题库解析

这门怎么题库答案不全啊日 来简单学一下子来 一、选择题&#xff08;可多选&#xff09; 将原始数据进行集成、变换、维度规约、数值规约是在以下哪个步骤的任务?(C) A. 频繁模式挖掘 B.分类和预测 C.数据预处理 D.数据流挖掘 A. 频繁模式挖掘&#xff1a;专注于发现数据中…...

蓝桥杯 2024 15届国赛 A组 儿童节快乐

P10576 [蓝桥杯 2024 国 A] 儿童节快乐 题目描述 五彩斑斓的气球在蓝天下悠然飘荡&#xff0c;轻快的音乐在耳边持续回荡&#xff0c;小朋友们手牵着手一同畅快欢笑。在这样一片安乐祥和的氛围下&#xff0c;六一来了。 今天是六一儿童节&#xff0c;小蓝老师为了让大家在节…...

对WWDC 2025 Keynote 内容的预测

借助我们以往对苹果公司发展路径的深入研究经验&#xff0c;以及大语言模型的分析能力&#xff0c;我们系统梳理了多年来苹果 WWDC 主题演讲的规律。在 WWDC 2025 即将揭幕之际&#xff0c;我们让 ChatGPT 对今年的 Keynote 内容进行了一个初步预测&#xff0c;聊作存档。等到明…...

Keil 中设置 STM32 Flash 和 RAM 地址详解

文章目录 Keil 中设置 STM32 Flash 和 RAM 地址详解一、Flash 和 RAM 配置界面(Target 选项卡)1. IROM1(用于配置 Flash)2. IRAM1(用于配置 RAM)二、链接器设置界面(Linker 选项卡)1. 勾选“Use Memory Layout from Target Dialog”2. 查看链接器参数(如果没有勾选上面…...

现代密码学 | 椭圆曲线密码学—附py代码

Elliptic Curve Cryptography 椭圆曲线密码学&#xff08;ECC&#xff09;是一种基于有限域上椭圆曲线数学特性的公钥加密技术。其核心原理涉及椭圆曲线的代数性质、离散对数问题以及有限域上的运算。 椭圆曲线密码学是多种数字签名算法的基础&#xff0c;例如椭圆曲线数字签…...

uniapp中使用aixos 报错

问题&#xff1a; 在uniapp中使用aixos&#xff0c;运行后报如下错误&#xff1a; AxiosError: There is no suitable adapter to dispatch the request since : - adapter xhr is not supported by the environment - adapter http is not available in the build 解决方案&…...

Java详解LeetCode 热题 100(26):LeetCode 142. 环形链表 II(Linked List Cycle II)详解

文章目录 1. 题目描述1.1 链表节点定义 2. 理解题目2.1 问题可视化2.2 核心挑战 3. 解法一&#xff1a;HashSet 标记访问法3.1 算法思路3.2 Java代码实现3.3 详细执行过程演示3.4 执行结果示例3.5 复杂度分析3.6 优缺点分析 4. 解法二&#xff1a;Floyd 快慢指针法&#xff08;…...