RNNs, LSTMs, GRUs学习以及Batch Size对模型影响的讨论

5 篇文章 0 订阅
2 篇文章 0 订阅

这是一辆搬运车以及一些小小的总结。

最近重新过了一遍RNNs和LSTMs的内容。看到了一些写的很好的博客,我想是作为Baby Steps很好的资源,把它们放在这里,和大家分享。

https://towardsdatascience.com/illustrated-guide-to-recurrent-neural-networks-79e5eb8049c9

这是一篇很推荐的关于RNNs的介绍和分析,同时还有Youtbue视频,大家可以看视频也可以看文字。分析了为什么RNNs存在short memory的原因,解释了反向传播过程中出现的梯度下降现象。我相信看完这篇文章,大家一定会对RNNs有转换为自己的知识的感受。 

Anyone Can Learn To Code an LSTM-RNN in Python (Part 1: RNN) - i am trask

这篇博客中,作者通过详细介绍广泛的Neural Memory, RNN中的Neural Network Memory以及反向传播三方面入手介绍了RNNs。并且辅以代码帮助理解。这是见过的非常详细宝贵且真诚的代码讲解了。

https://towardsdatascience.com/illustrated-guide-to-lstms-and-gru-s-a-step-by-step-explanation-44e9eb85bf21

和第一篇博客是同一个作者,这篇紧接着第一篇博文中提到的RNNs的short memory问题,生动介绍了LSTMs和GRUs。

https://colah.github.io/posts/2015-08-Understanding-LSTMs/

 同时,这里再附上一篇关于LSTM的Step-by-step的介绍。

看完上面的四篇博客,大家一定会对RNNs这个家族有一定的人数。也会有一个思考

Do larger hidden dimensions make things train faster or slower?下面的这篇博客就做了一个有趣的分析,也回答了这个问题。

https://medium.com/mini-distill/effect-of-batch-size-on-training-dynamics-21c14f7a716e

这篇博文中详细讨论了batch size 对训练过程的影响,并辅以实验数据分析。

最后在这里提供一个关于neural network的toy example

A Neural Network in 11 lines of Python (Part 1) - i am trask 

以下是我的一些小小笔记,有点乱,请谅解。

An RNN has a looping mechanism that acts as a highway to allow information to flow from one step to the next.

 ---information: hidden state

 ---hidden state: a representation of previous inputs

First, you initialize your network layers and the initial hidden state.

 ---The shape and dimension of the hidden state will be dependent on the shape and dimension of your recurrent neural network.

Then you loop through your inputs, pass the word and hidden state into the RNN.

The RNN returns the output and a modified hidden state.

You continue to loop until you're out of words.

Last you pass the output to the feed-forward layer, and it returns a prediction.

The control flow of doing a forward pass of a recurrent neural network is a for loop.

训练神经网络的三大步骤:

First, it does a forward pass and makes a prediction.

【先通过forward pass做预测。】

Second, it compares the prediction to the ground truth using a loss function. The loss function outputs an error value which is an estimate of how poorly the network is performing.

然后,用loss函数将预测结果和事实作比较计算出一个误差值,用来评估网络的预测效果。】

 Last, it uses that error value to do back propagation which calculates the gradients for each node in the network.

最后,用得到的错误值做反向传播来计算网络中每个节点的梯度。

Gradient梯度

为什么要计算梯度(梯度用在哪里?)

New weight = Weight - Learning Rate * Gradient

the value used to adjust the networks internal weights (目的是allowing the network to learn)

【用于调整网络的内部权重,使网络去学习】

梯度消失 vanish gradient

Caused by back-propagation 【而为什么使反向传播引发梯度下降呢?因为反向传播用到的使chain rule,所以准确说来是使chain rule引发的梯度消失】

Each time step in a recurrent neural network as a layer. 

每个time step就是一层。】

The gradient values will exponentially shrink as it propagates through each time step.

【梯度会呈指数缩小。】

Small gradients mean small adjustments. That causes the early layers not to learn.

数值小的荼毒意味着对weight的微小调整,而权重的调整其实是神经网络去学习的核心目的。既然weight变化小就说明神经网络没怎么学习,即网络训练效果差。---这种情况尤其容易发生在earlier lays上,这也是为什么RNNs的memory短的根本原因。

Memory:

Means that the hidden layer is a combination of the input data and the previous hidden layer.

Memory是输入数据和前一个hidden layer 的结合得到的新的hidden layer

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值