Reputation: 5936
The constructor for many of the RNN classes (BasicRNNCell
, LSTMCell
, and so on) accepts an argument named num_units
. This sets the number of units in the cell.
I thought this identified the number of elements the RNN should process in sequence. So if you want an RNN to process sequences of length N, you'd have N units per cell. Is this correct? What exactly is an RNN unit?
Upvotes: 0
Views: 1161
Reputation: 21
here num_units refers to the number of units in LSTM(or rnn) cell.
num_units can be interpreted as the analogy of hidden layer from the feed forward neural network.The number of nodes in hidden layer of a feed forward neural network is equivalent to num_units number of LSTM units in a LSTM cell at every time step of the network.Following picture should clear any confusion- enter image description here
(cited from https://jasdeep06.github.io/posts/Understanding-LSTM-in-Tensorflow-MNIST/
Upvotes: 2
Reputation: 135
No, it's not correct.
num_units
refers to the number of features your cells can represent. At each time step, you give an input of a certain size (that you are calling "the number of elements the RNN should process in sequence"). This is like the layer 0 of your neural network. This input is then processed into a hidden layer, with size num_units
. This is also the size of the cell output.
What you call N, is set by the size of your inputs tensor. num_units
is a hyperparameter of your model. The bigger it is, the more degrees of freedom your model has (more descriptive features).
Upvotes: 3