LSTM Networks

1. Recurrent Neural Network (RNN)

Compare to traditional neural network, RNN can work on persistence model, which means the current state is depending on the past states.

For example, imagine you want to classify what kind of event is happening at every point in a movie. It’s unclear how a traditional neural network could use its reasoning about previous events in the film to inform later ones [1].



However, RNN can only work well on short-term dependencies, as that gap grows, RNNs become unable to learn to connect the information.


2. LSTM Networks

Long Short Term Memory Networks (LSTM) is a special kind of RNN, which is also capable of learning long-term dependencies.



LSTM also have this chain like structure, but the repeating module has a different structure. Instead of having a single neural network layer, LSTM has four and the four interacting in a special way.




The key to LSTMs is the cell state, the horizontal line running through the top of the diagram.


The LSTM does have the ability to remove or add information to the cell state, carefully regulated by structures called gates. Gates are a way to optionally let information through. They are composed out of a sigmoid neural network layer and a pointwise operation.

The sigmoid layer outputs numbers between zero and one, describing how much of each component should be let through. A value of zero means “let nothing through,” while a value of one means “let everything through!”

An LSTM has three of these gates, to protect and control the cell state.

3. Step by Stey LSTM Walk Through

a)The first step in our LSTM is to decide what information we’re going to throw away from the cell state. 



b) The next step is to decide what new information we’re going to store in the cell state. 

This has two parts. First, a sigmoid layer called the “input gate layer” decides which values we’ll update. Next, a tanh layer creates a vector of new candidate values,  C~t, that could be added to the state. In the next step, we’ll combine these two to create an update to the state.



It’s now time to update the old cell state, Ct−1, into the new cell state Ct.



c) Finally, we need to decide what we’re going to output. 

This output will be based on our cell state, but will be a filtered version. 



4. Variants on LSTM

a) Adding “peephole connections.” This means that we let the gate layers look at the cell state.



b) using coupled forget and input gates. 

Instead of separately deciding what to forget and what we should add new information to, we make those decisions together. We only forget when we’re going to input something in its place. We only input new values to the state when we forget something older.



c) Gated Recurrent Unit, or GRU

It combines the forget and input gates into a single “update gate.” It also merges the cell state and hidden state, and makes some other changes. 



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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LSTM (Long Short-Term Memory) is a type of recurrent neural network (RNN) architecture that is commonly used for sequence data analysis, including time series analysis and natural language processing. In MATLAB, you can use the Deep Learning Toolbox to build and train LSTM networks. To create an LSTM network in MATLAB, you can use the `lstmLayer` function to specify the number of hidden units and any additional options. You can then use the `sequenceInputLayer`, `fullyConnectedLayer`, and `classificationLayer` functions to define the input, output, and classification layers of the network, respectively. Finally, you can use the `trainNetwork` function to train the LSTM network using your training data. Here is an example of how to create and train an LSTM network in MATLAB: ```matlab % Define the LSTM network architecture numHiddenUnits = 100; layers = [ ... sequenceInputLayer(inputSize) lstmLayer(numHiddenUnits) fullyConnectedLayer(numClasses) softmaxLayer classificationLayer]; % Set training options options = trainingOptions('adam', 'MaxEpochs', 20); % Train the LSTM network net = trainNetwork(XTrain, YTrain, layers, options); ``` In this example, `inputSize` represents the size of your input data, `numClasses` represents the number of classes in your classification problem, `XTrain` is the input training data, and `YTrain` is the corresponding target training data. You can then use the trained LSTM network to make predictions on new data using the `classify` function: ```matlab YPred = classify(net, XTest); ``` I hope this helps you get started with using LSTM networks in MATLAB! Let me know if you have any further questions.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值