I tried very hard to search everywhere, but I couldn't find what num_units
in TensorFlow actually is. I tried to relate my question to this question, but I couldn't get clear explanation there.
In TensorFlow, when creating an LSTM-based RNN, we use the following command
cell = rnn.BasicLSTMCell(num_units=5, state_is_tuple=True)
As Colah's blog says, this is a basic LSTM cell:
Now, suppose my data is:
idx2char = ['h', 'i', 'e', 'l', 'o']
# Teach hello: hihell -> ihello
x_data = [[0, 1, 0, 2, 3, 3]] # hihell
x_one_hot = [[[1, 0, 0, 0, 0], # h 0
[0, 1, 0, 0, 0], # i 1
[1, 0, 0, 0, 0], # h 0
[0, 0, 1, 0, 0], # e 2
[0, 0, 0, 1, 0], # l 3
[0, 0, 0, 1, 0]]] # l 3
y_data = [[1, 0, 2, 3, 3, 4]] # ihello
My input is:
x_one_hot = [[[1, 0, 0, 0, 0], # h 0
[0, 1, 0, 0, 0], # i 1
[1, 0, 0, 0, 0], # h 0
[0, 0, 1, 0, 0], # e 2
[0, 0, 0, 1, 0], # l 3
[0, 0, 0, 1, 0]]] # l 3
which is of shape [6,5]
.
In this blog, we have the following picture
As far as I know, the BasicLSTMCell
will unroll for t
time steps, where t
is my number of rows (please, correct me if I am wrong!). For example, in the following figure, the LSTM is unrolled for t = 28
time steps.
In the Colah's blog, it's written
each line carries an entire vector
So, let's see how my [6,5]
input matrix will go through this LSTM-based RNN.
If my above diagram is correct, then what exactly is num_units
(which we defined in LSTM cell)? Is it a parameter of an LSTM cell?
If num_unit
is a parameter of a single LSTM cell, then it should be something like:
If above diagram is correct, then where are those 5 num_units
in the following schematic representation of the LSTM cell (according to Colah's blog)?
If you can give your answer with a figure, that would be really helpful! You can edit or create new whiteboard diagram here.