其他分享
首页 > 其他分享> > cs224n - Vanishing Gradients and Fancy RNNs

cs224n - Vanishing Gradients and Fancy RNNs

作者:互联网

Vanishing Gradients and Fancy RNNs

Vanishing gradient problem

图片名称

Why is vanishing gradient a problem?

图片名称

Another explanation: Gradient can be viewed as a measure of
the effect of the past on the future. If the gradient becomes vanishingly small over longer distances (step t to step t+n), then we can’t tell whether:

Effect of vanishing gradient on RNN-LM

图片名称

Why is exploding gradient a problem?

If the gradient becomes too big, then the SGD update step
becomes too big:
\[ \theta^{\text {new}}=\theta^{\text { old }}-\alpha \nabla_{\theta} J(\theta) \]
This can cause bad updates: we take too large a step and reach
a bad parameter configuration (with large loss). In the worst case, this will result in Inf or NaN in your network (then you have to restart training from an earlier checkpoint).

Gradient clipping: solution for exploding gradient

Gradient clipping: if the norm of the gradient is greater than
some threshold, scale it down before applying SGD update

Intuition: take a step in the same direction, but a smaller step

图片名称

How to fix vanishing gradient problem?

The main problem is that it’s too difficult for the RNN to learn to preserve information over many timesteps. In a vanilla RNN, the hidden state is constantly being rewritten:
\[ \boldsymbol{h}^{(t)}=\sigma\left(\boldsymbol{W}_{h} \boldsymbol{h}^{(t-1)}+\boldsymbol{W}_{x} \boldsymbol{x}^{(t)}+\boldsymbol{b}\right) \]

Long Short-Term Memory (LSTM)

图片名称 图片名称

How does LSTM solve vanishing gradients?

Gated Recurrent Units (GRU)

图片名称

LSTM vs GRU

Conclusion: Though vanishing/exploding gradients are a general
problem, RNNs are particularly unstable due to the repeated
multiplication by the same weight matrix

Bidirectional RNNs

图片名称

Multi-layer RNNs

图片名称

标签:gradient,problem,boldsymbol,Vanishing,step,LSTM,cs224n,Gradients,vanishing
来源: https://www.cnblogs.com/curtisxiao/p/10666150.html