I changed the output variable in the training loop before passing it in the loss function.
output = output[:, -1, :]
This selects the last element of the sequence in each batch.
I don’t get the size mismatch error anymore.
Thanks a lot!