I have LSTM with 3 inputs and 1 output. Dataset returns ((tensor1, tensor2, tensor3), tensor_target). How to reshape my Dataset outputs to make in work with LSTM input?
batch_size = 5
n_hidden = 1
encoder_size = 64*2*2
seq_len = 3
rnn = nn.LSTM(encoder_size, encoder_size, n_hidden)
input = torch.randn(seq_len, batch_size, encoder_size) # how to reshape to this shape?
output, (hn, cn) = rnn(input)
this looks like a simple lstm, cant you use tensor.view(seq_len, batch_size, encoder_size)?
I can not use tensor.view because
is not a tensor
It’s less about reshaping but converting your input tuple
(tensor1, tensor2, tensor3) to a tensor. What you can do is, for example:
input = torch.zeros(3, batch_size, encoder_size)
tensor, tensor, tensor = tensor1, tensor2, tensor3
This assumes that
tensor1.shape = (batch_size, encoder_size); same of
tensor3, of course. If the shapes are
(seq_len, encoder_size) then you have to adopt the code a bit. But I cannot tell which shapes your tensors have.