I was not calling model.train and directly calculating the y_hat.So, I changed to -
test_dl = DataLoader(tst_data, batch_size=64, shuffle=False)
test = []
print(‘Predicting on test dataset’)
model = model.to(device)
for batch, _ in tst_data:
batch=batch.to(device)
out = model.train()(batch)
y_hat = F.log_softmax(out, dim=1).argmax(dim=1)

However, I got another issue not:
<torch.utils.data.dataset.TensorDataset object at 0x7f0d61a87490>
Predicting on test dataset
torch.Size([1, 4000, 500])
4000
1
torch.Size([4000])
RuntimeError                              Traceback (most recent call last)
 in ()
6 for batch, _ in tst_data:
7     batch=batch.to(device)
----> 8     out = model.train()(batch)
9     y_hat = F.log_softmax(out, dim=1).argmax(dim=1)
10
5 frames
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/rnn.py in check_input(self, input, batch_sizes)
201             raise RuntimeError(
202                 ‘input must have {} dimensions, got {}’.format(
 → 203                     expected_input_dim, input.dim()))
204         if self.input_size != input.size(-1):
205             raise RuntimeError(
RuntimeError: input must have 3 dimensions, got 1
Could you please look.