I am trying to create a multi-layer recurrent neural network with GRU units (as well be LSTM units) in tensorflow. I have looked at multiple sources, including the official tutorial. But I keep seeing the following pattern for multi-layer RNNs (shown here with GRU units).
cell = GRUCell(num_neurons) # Or LSTMCell(num_neurons)
cell = DropoutWrapper(cell, output_keep_prob=dropout)
cell = MultiRNNCell([cell] * num_layers)
This code snippet is taken from RNN Tensorflow Introduction. My understanding of [cell] * num_layers
is that the same object cell
gets referenced num_layer
times in the list. So, won't the MultiRNNCell
be creating a deep network where the each layer has the same weights as the previous ones. If someone can clarify what's exactly happening here, it would be very insightful.
tf.nn.dynamic_rnn(cell, x, initial_state=Hin)
. From what I understand, theHin
will carry the states of the GRU / LSTM units, which means, it also has the weights per layer. – afagarap