Hello, I am trying to implement a LSTM but I am getting an error when running the forward
function.
I intialized my model like this:
m = nn.LSTM(input_size = 8, hidden_size = 128, num_layers = 1,dropout=0.1,bidirectional=0,batch_first=True)
And then, when doing this:
m.forward(batch[0])
I get the following error:
lstm() received an invalid combination of arguments - got (Tensor, tuple, list, bool, int, float, bool, int, bool), but expected one of:
- (Tensor data, Tensor batch_sizes, tuple of Tensors hx, tuple of Tensors params, bool has_biases, int num_layers, float dropout, bool train, bool bidirectional)
didn’t match because some of the arguments have invalid types: (Tensor, !tuple!, !list!, !bool!, !int!, !float!, !bool!, !int!, bool)- (Tensor input, tuple of Tensors hx, tuple of Tensors params, bool has_biases, int num_layers, float dropout, bool train, bool bidirectional, bool batch_first)
didn’t match because some of the arguments have invalid types: (Tensor, !tuple!, !list!, bool, int, float, bool, !int!, bool)
My batch[0] data:
tensor([[[ 0., 0., 0., 0., 0., 0., 0., 0.],
[ 20., 0., 0., 0., 0., 0., 0., 0.],
[ 65., 0., 0., 0., 0., 0., 0., 0.],
[ 118., 0., 0., 0., 0., 0., 0., 0.],
[ 165., 0., 0., 0., 0., 0., 0., 0.],
[-269., 0., 0., 0., 0., 0., 0., 0.],
[-269., 0., 0., 0., 0., 0., 0., 0.],
[ 175., 0., 0., 0., 0., 0., 0., 0.],
[ 243., 0., 0., 0., 0., 0., 0., 0.],
[ 214., 0., 0., 0., 0., 0., 0., 0.],
[ 559., 0., 0., 0., 0., 0., 0., 0.],
[ 617., 0., 0., 0., 1., 0., 0., 0.],
[-269., 0., 0., 1., 0., 0., 0., 0.],
[-269., 0., 1., 0., 0., 0., 0., 0.],
[-269., 1., 0., 0., 0., 0., 0., 0.],
[ 437., 0., 0., 0., 0., 1., 0., 0.],
[ 396., 0., 0., 0., 0., 0., 1., 0.],
[ 517., 0., 0., 0., 0., 0., 0., 1.],
[ 656., 0., 0., 0., 0., 0., 0., 0.],
[-269., 0., 0., 0., 0., 0., 0., 0.],
[-269., 0., 0., 0., 0., 0., 0., 0.],
[ 549., 0., 0., 0., 0., 0., 0., 0.],
[ 595., 0., 0., 0., 0., 0., 0., 0.],
[ 453., 0., 0., 0., 0., 0., 0., 0.],
[ 600., 0., 0., 0., 0., 0., 0., 0.],
[ 839., 0., 0., 0., 0., 0., 0., 0.],
[-269., 0., 0., 0., 0., 0., 0., 0.],
[-269., 0., 0., 0., 0., 0., 0., 0.]]])
Any idea on what I am doing wrong? I thought that it could be the way I am intializing my NN so I added the arguments name to the constructor but it doesnt seem to help.
Any suggestion is appreciated!
Kind regards