3

I am in trouble with understanding the concept of LSTM and using it on Keras. When considering a LSTM layer, there should be two values for output size and the hidden state size.

1. hidden state size : how many features are passed across the time steps of a samples when training the model
2. output size       : how many outputs should be returned by particular LSTM layer

But in keras.layers.LSTM, there is only one parameter and it is used to control the output size of the layer.

PROBLEM:

Therefore how hidden state size of the LSTM layer can be changed?

If I am misunderstood, corrections are really appreciated.

user11851100
  • 37
  • 1
  • 5
  • Similar questions: https://ai.stackexchange.com/questions/15621/what-is-the-relationship-between-the-size-of-the-hidden-layer-and-the-size-of-th and https://stats.stackexchange.com/questions/468927/when-computing-parameters-why-is-dimensions-of-hidden-output-state-of-an-lstm-c – toliveira Nov 12 '20 at 21:03

2 Answers2

2

Referring to this article:

As far as I understand, the hidden state size of an LSTM is called units in keras. The size of the output then depends on how many time steps there are in the input data and what the dimension of the hidden state (units) is. This could also become clearer when looking at this post.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
kettu
  • 21
  • 3
-2

You are getting confused between the difference in hidden units and output units in LSTM. Please refer to the below link for better clarity:

https://jasdeep06.github.io/posts/Understanding-LSTM-in-Tensorflow-MNIST/

Basically what you provide in num_units is the size of LSTM hidden unit only. This is very clear from this article.

AG_Gurgaon
  • 19
  • 4