Question

From Tensorflow code: Tensorflow. RnnCell.

num_units: int, The number of units in the LSTM cell.

Can't undestand what does this mean. What are the units of LSTM cell. Input, Output and forget gates? Does this mean "number of units in the recurrent projection layer for Deep LSTM". Then why does this is called "number of units in the LSTM cell"? What is LSTM cell and what is difference VS LSTM block, what is minimal LSTM unit if not cell?

Was it helpful?

Solution

As the helpful comments in that function say,

The definition of cell in this package differs from the definition used in the literature. In the literature, cell refers to an object with a single scalar output. The definition in this package refers to a horizontal array of such units.

In essence, the layer will contain multiple parallel LSTM units, structurally identical but each eventually "learning to remember" some different thing.

OTHER TIPS

Most LSTM/RNN diagrams just show the hidden cells but never the units of those cells. Hence, the confusion. Each hidden layer has hidden cells, as many as the number of time steps. And further, each hidden cell is made up of multiple hidden units, like in the diagram below. Therefore, the dimensionality of a hidden layer matrix in RNN is (number of time steps, number of hidden units).

enter image description here

In Keras, which sits on top of either TensorFlow or Theano, when you call model.add(LSTM(num_units)), num_units is the dimensionality of the output space (from here, line 863). To me, that means num_units is the number of hidden units whose activations get sent forward to the next time step.

Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top