LSTM (Explained by Li Hongyi)

1. First of all, a feature input, there will be an input gate to control whether it can be input, and then when it needs to output after learning, it needs an output gate to control whether to output or not. Inside this memory cell, there will be a forgetting gate. Control whether the cell should forget the information.

So lstm has four inputs: information to be input from the outside world, input gate, forgetgate, output gate

 Figure 1 lstm

2. The lstm structure is abstracted as follows. It is obvious that there are four inputs

Input signal: Z

Input gate: Zi, only when this value is exceeded, the input gate can be opened and the data Z can be input

forgetgate: Zf, only when this value is exceeded can the forget gate be opened, remember. close is forget

output gate: Zo, only when this value is exceeded, the output gate can be opened and the signal is output as a

 3.

 4. LSTM example

First set the rules, that is, three gates: when x2 is equal to 1, the data can be input to the memory cell; when x2 is equal to -1, the data is forgotten; when x3 is equal to 1, the data can be output

The blue one on the top is the memory cell, which is 0 at the beginning

The first column is 0, and x2 is equal to 1 in the second column, then x1 is written to the memory cell, that is, 3 is written to the memory cell (the blue block in the third column)

The third column x2 and x3 are both 0, do not operate, the fourth column x2 is equal to 1, then the 4 of x1 is written to the memory cell (3+4=7), the fifth column x2 and x3 are both 0, do not operate, The sixth column x3 is equal to 1, and the output memory cell is 7, so y is equal to 7

 

 

5.ct-1 is the cell, xt is the input, and the four green ones below are the aforementioned input gate control, output gate control, and forget gate control

 6.

 

 

 

Guess you like

Origin blog.csdn.net/qq_46073783/article/details/131483881