Open davide-burba opened 4 years ago
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
dataX.transpose(0,1)
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.
Inside LSTM class:
change this:
to this:
also, when you train/predict the model, use
dataX.transpose(0,1)
as inputCheck 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.