Stacked LSTM with same hidden input

(lankanatha) #1

i need to be stacked two LSTM with same parallel hidden input, how can I add one after another,

class DecoderRNN(nn.Module):
def init(self, embed_size, hidden_size, vocab_size, num_layers, max_seq_length):
“”“Set the hyper-parameters and build the layers.”""
super(DecoderRNN, self).init()
self.embed = nn.Embedding(vocab_size, embed_size)
self.lstm1 = nn.LSTM(embed_size, hidden_size, num_layers, batch_first=True)
self.linear = nn.Linear(hidden_size, vocab_size)
self.max_seg_length = max_seq_length
self.init_weights() # initialize weigts
def init_weights(self):
“”“Initialize the weights.”""
self.linear.weight.data.normal_(0.0, 0.02)
self.linear.bias.data.fill_(0)