MATLAB Answers

LSTM cell operation with different number of hidden units

35 views (last 30 days)
Neon Argentus
Neon Argentus on 10 Jul 2020
Answered: Asvin Kumar on 3 Aug 2020
In this link, workings of LSTM in MATLAB is explained to some degree, however I need some clarification:
Let, I have 400 time steps where each will include 100-long feature vectors.
a) Assume I set LSTM hidden unit number to 1. From my intuition, from time 0 to 399, this unit will receive all feature vectors in order and process them sequentially till the end, 400th vector at step 399.
b) Now assume hidden unit number is 50. Then what I understant from documentation is, the 50 stacked units will receive first feature vector at time step 0, and of course they will receive inputs from each other depending on the hidden unit topology. At time step 1, second feature vector will propagate through the topology with other inputs and so on.
Did I interpret it right or miss something else?
Another question, when I set LSTM hidden layer number to 50, how do I know the topology?

  0 Comments

Sign in to comment.

Accepted Answer

Asvin Kumar
Asvin Kumar on 3 Aug 2020
For your question, I am going to refer you to an earlier answer of mine:
Have a closer look at this link from that answer to the definition of the ‘numHiddenUnits’ property:
I’m also going to refer you back to the LSTM Layer Architecture section in the link you mentioned.
As you can see, it is always a sequential topology.
Think of it this way, the LSTM Network unrolls to the length of your sequence. The hidden state (with height numHiddenUnits) and the cell state from the first LSTM Cell will get passed onto the second LSTM Cell. The second LSTM cell receives them both and in addition it will also receive the second input. The second cell’s hidden state and cell state will get passed onto the third cell state. This way, the LSTM unrolls to the length of your sequence.
Note: You are only setting the number of hidden units (a.k.a the length of the hidden state). You are not setting the number of cells of the LSTM.

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!