@ptrblck @vdw I have a same problems. I printed the inputs shape and h_0, c_0 shape to check and found the batch_size was changed.
The full error log below
Enum count: 133
input:  torch.Size([250, 25, 300]) h_0:  torch.Size([1, 25, 256]) c_0:  torch.Size([1, 25, 256])
validation - Input shape issue torch.Size([22, 250])
Enum count: 134
input:  torch.Size([250, 372, 300]) h_0:  torch.Size([1, 25, 256]) c_0:  torch.Size([1, 25, 256])
Traceback (most recent call last):
File “lstm_pytorch.py”, line 290, in 
main()
File “lstm_pytorch.py”, line 286, in main
do_cnn()
File “lstm_pytorch.py”, line 270, in do_cnn
acc, sentence_vec = train_test_one_split(cv, train_index, test_index)
File “lstm_pytorch.py”, line 256, in train_test_one_split
eval_acc, sentence_vector = evaluate(model, x_test, y_test)
File “lstm_pytorch.py”, line 139, in evaluate
preds, vector = model(inputs)
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “lstm_pytorch.py”, line 126, in forward
input, (h_0, c_0))
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\module.py”, line 493, in call
result = self.forward(*input, **kwargs)
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\rnn.py”, line 559, in forward
return self.forward_tensor(input, hx)
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\rnn.py”, line 539, in forward_tensor
output, hidden = self.forward_impl(input, hx, batch_sizes, max_batch_size, sorted_indices)
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\rnn.py”, line 519, in forward_impl
self.check_forward_args(input, hx, batch_sizes)
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\rnn.py”, line 494, in check_forward_args
‘Expected hidden[0] size {}, got {}’)
File “E:\Anaconda3\envs\keras-gpu\lib\site-packages\torch\nn\modules\rnn.py”, line 172, in check_hidden_size
raise RuntimeError(msg.format(expected_hidden_size, tuple(hx.size())))
RuntimeError: Expected hidden[0] size (1, 372, 256), got (1, 25, 256)