Encoder LSTM
class Encoder(nn.Module):
def __init__(self, vocab_len, embedding_dim, hidden_dim, n_layers, dropout_prob):
super().__init__()
self.embedding = nn.Embedding(vocab_len, embedding_dim)
self.rnn = nn.LSTM(embedding_dim, hidden_dim, n_layers, dropout=dropout_prob)
self.dropout = nn.Dropout(dropout_prob)
def forward(self, input_batch):
embed = self.dropout(self.embedding(input_batch))
outputs, (hidden, cell) = self.rnn(embed)
return hidden, cell