Hi,
I am new to pytorch and want to implement a pytorch version of below seq2seq model (char-level translation, a keras example):
https://keras.io/examples/lstm_seq2seq/
I defined the encoder and decoder but does not know how to continue, anyone can help or is there an online implementation? Many thanks.
class encoder(nn.Module):
def __init__(self):
super(encoder,self).__init__()
self.LSTM=nn.LSTM(input_size=num_encoder_tokens,hidden_size=256,batch_first=True)
def forward(self,x):
out,(h,c)=self.LSTM(x)
return h,c
class decoder(nn.Module):
def __init__(self):
super(decoder,self).__init__()
self.LSTM=nn.LSTM(input_size=num_decoder_tokens,hidden_size=256,batch_first=True)
self.FC=nn.Linear(256,num_decoder_tokens)
def forward(self,x,hidden_states):
out,(h,c)=self.LSTM(x,hidden_states)
out=self.FC(out[:, -1, :])
return out,(h,c)