Huh, that’s written in the docs for GRU:


batch_first – If True , then the input and output tensors are provided as (batch, seq, feature). Default: False





 alvations:

[…] but it was the fastest hack to modify the shape to what I’ll need.


That’s exactly my concern I have with many codes I see: just tweak so PyTorch won’t complain :). Your self.classifier = nn.Linear(hidden_size, vocab_size) will take anything as input that is of shape (x, hidden_size) where x can basically anything since it’s treated as the batch size.
Did you try output = output[-1] and check the shape afterwards? It should be (batch_size, hidden_size) and raise no error when calling forward(). Please not that this only works if batch_first=False, otherwise you need to transpose() first or something (I just saw that you use batch_first=True now)
What does the network trying to train in layman terms. both Kaggle links have no further comments or descriptions. How does an individual training data item looks like? Is X a sequence of words and y the next predicted word?