spdin/time-series-prediction-lstm-pytorch

lstm input is wrong

davide-burba opened this issue · 0 comments

Inside LSTM class:

change this:

ula, (h_out, _) = self.lstm(x, (h_0, c_0))
h_out = h_out.view(-1, self.hidden_size)

to this:

h_out, _ = self.lstm(x, (h_0, c_0))
h_out = h_out.view(-1,x.size(1),self.hidden_size)[-1] 

also, when you train/predict the model, use dataX.transpose(0,1) as input

Check https://pytorch.org/docs/stable/nn.html?highlight=lstm#torch.nn.LSTM for reference on input/output formatting for LSTM layer

Now you can use multiple layers.