8I am trying to build an LSTM model for time series data. The details of dataset :
Input data is time series with 800 subjects, each having a 2D array data of 60 rows and 200 columns. I loaded the entire data as a Tensor of shape [800,60,200] and labels for the classification problem is of shape [800,1].
I made a dictionary of the data using the following code :
class DataCurate(Dataset):
def init(self, l1,l2, transform=None):
self.l1=l1
self.l2=l2
self.transform=transform
def len(self):
return len(self.l1)
def getitem(self, index):
array=self.l1[index]
label=self.l2[index]
sample = {‘time_data’: array, ‘labels’: label}
return sample
the data and labels are in variables x & y. I call data=Datacurate(x,y)
Later on I build and LSTM model for classification problem using the code:
class RNNModel(nn.Module):
def init(self, input_size, hidden_size, num_layers, num_classes):
super(RNNModel, self).init()
self.hidden_size = hidden_size
self.num_layers = num_layers
self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True) #inputsize=200,hid_size=320,n_layer=2
self.linear = nn.Linear(hidden_size, num_layers, bias=True)
#self.linear.apply(weights_init)
self.softmax = nn.LogSoftmax()
def forward(self, x)
    self.lstm.flatten_parameters()
    out_packed, state = self.lstm(x)  # RNN
    print("lstm output size: {out.size()}"+str(out_packed.size()))
    out = self.linear(out_packed[-1])  # linear transform
print("linear output size {out.size()} "+str(out.size()))
log_probs = F.log_softmax(out,dim=1)
print("softmax output size {log_probs.size()}"+str(log_probs.size()))
    return log_probs

This gives me an error when I run the training script:
UserWarning: RNN module weights are not part of single contiguous chunk of memory. This means they need to be compacted at every call, possibly greatly increasing memory usage. To compact weights again call flatten_parameters().
out_packed, state = self.lstm(x)  # RNN
Traceback (most recent call last):
File “main_2.py”, line 100, in 
output = model(train_inputs.transpose(0,1))
File “/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py”, line 477, in call
result = self.forward(*input, **kwargs)
File “/media/iab/disk_a/meghal/test/quickdraw_tutorial_dataset_v1/pytorch_RNN_examples/model.py”, line 26, in forward
out_packed, state = self.lstm(x)  # RNN
File “/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py”, line 477, in call
result = self.forward(*input, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/torch/nn/modules/rnn.py”, line 192, in forward
output, hidden = func(input, self.all_weights, hx, batch_sizes)
File “/usr/local/lib/python3.5/dist-packages/torch/nn/_functions/rnn.py”, line 324, in forward
return func(input, *fargs, **fkwargs)
File “/usr/local/lib/python3.5/dist-packages/torch/nn/_functions/rnn.py”, line 288, in forward
dropout_ts)
RuntimeError: param_from.type() == param_to.type() ASSERT FAILED at /pytorch/aten/src/ATen/native/cudnn/RNN.cpp:491, please report a bug to PyTorch. parameter types mismatch
I don’t know what this means and how do I resolve it. I am completely new to LSTM.